/* ============================================================
   VPN Панель — оформление кабинета simreg.

   Цвета, скругления и тени — только токенами из tokens.css (копия
   public/ui/tokens.css кабинета). Цвет значением здесь один — белая подложка
   QR-кода: сканер читает тёмные модули на светлом в любой теме.

   Правила перенесены из public/ui/shell.css, table.css, forms.css и
   metrics.css кабинета и подогнаны под серверную разметку панели: в кабинете
   её собирает JS, здесь — шаблоны Jinja, поэтому шторка меню и меню
   пользователя работают без скриптов (флажок + label, details/summary).

   Тема — как в системе: светлую и тёмную ветки токенов переключает
   prefers-color-scheme.
   ============================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Соты на фоне и бродящее по ним свечение — как у кабинета (shell.css):
   отдельные fixed-слои под содержимым, чтобы узор не уезжал с прокруткой. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image: var(--grid);
  background-repeat: repeat;
  background-size: var(--grid-tile);
  background-position: var(--grid-offset);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: var(--glow-strength);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(var(--glow-rgb), 1) 0%, rgba(var(--glow-rgb), .5) 42%, rgba(var(--glow-rgb), 0) 70%),
    radial-gradient(circle at 50% 50%, rgba(var(--glow-rgb), .85) 0%, rgba(var(--glow-rgb), .35) 45%, rgba(var(--glow-rgb), 0) 72%);
  background-repeat: no-repeat, no-repeat;
  background-size: 760px 760px, 540px 540px;
  -webkit-mask-image: var(--grid-mask); mask-image: var(--grid-mask);
  -webkit-mask-repeat: repeat; mask-repeat: repeat;
  -webkit-mask-size: var(--grid-tile); mask-size: var(--grid-tile);
  -webkit-mask-position: var(--grid-offset); mask-position: var(--grid-offset);
  animation: glow-drift 56s ease-in-out infinite;
}
@keyframes glow-drift {
  0%   { background-position: 12% 18%, 82% 74%; }
  13%  { background-position: 63% 6%,  21% 88%; }
  26%  { background-position: 89% 47%, 46% 21%; }
  38%  { background-position: 30% 71%, 93% 11%; }
  51%  { background-position: 5% 91%,  65% 60%; }
  63%  { background-position: 71% 28%, 11% 36%; }
  77%  { background-position: 40% 55%, 87% 93%; }
  88%  { background-position: 96% 80%, 33% 5%; }
  100% { background-position: 12% 18%, 82% 74%; }
}

a { color: var(--link); }
.num { font-variant-numeric: tabular-nums; }
.mono, code, textarea.conf { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }
code {
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 1px 6px; overflow-wrap: anywhere; word-break: break-all;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-radius: 6px;
}
/* У полей своя рамка — кольцо поверх неё читалось бы второй рамкой
   (shell.css кабинета). Признак фокуса у них — подсвеченная граница. */
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus-visible { box-shadow: none; }

/* Размеры — как у кабинета (сверено getComputedStyle на его ui-stand): h1 20/650/-.02em, h2 15/650,
   межстрочный 1.5 от body. Закреплено тестом tests/test_design.py. */
h1 { margin: 0 0 14px; font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 650; }
p.muted, .card p.muted { font-size: 13px; }

/* ---------------- каркас ---------------- */

.app {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh; position: relative;
}
.pane { min-width: 0; display: flex; flex-direction: column; grid-column: 2; grid-row: 1; }
.side { grid-column: 1; grid-row: 1; }

/* Флажок шторки: состояние меню на телефоне без скриптов. Сам невидим,
   управляют им две label — кнопка меню в шапке и подложка. */
.navtoggle { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; margin: 0; }

.side {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 14px 12px; gap: 2px;
  position: sticky; top: 0; height: 100vh;
  /* Список темы раскрывается вправо за край меню — на широком экране меню его не обрезает
     (разделов меньше десятка, прокручивать нечего). На узком шторка прокручивается сама. */
  overflow: visible;
}
.navgroup { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
/* Шапка меню — кнопка закрепления, как у кабинета (.sidehead): по центру полосы шапки страницы. */
.sidehead {
  display: flex; align-items: center;
  margin-top: calc((var(--top-h) - 34px) / 2 - 14px);
  padding: 0 0 4px;
}
.sidehead + .navgroup { margin-top: 4px; }
/* Кнопка меню #menuBtn — одна, как у кабинета: в шапке меню на широком экране, первой в шапке
   страницы на узком (переносит app.js). Без JS ей нечего делать: её нет, а на узком экране вместо неё
   label .menubtn, который переключает флажок шторки сам. Переключателя темы без JS тоже нет. */
html:not(.js) .sidehead, html:not(.js) #menuBtn, html:not(.js) .themepick { display: none; }
html:not(.js) .sidehead + .navgroup { margin-top: calc((var(--top-h) - 34px) / 2 - 2px); }
html.js .menubtn { display: none !important; }
.menubtn .ico-close, .navtoggle:checked ~ .pane .menubtn .ico-menu { display: none; }
.navtoggle:checked ~ .pane .menubtn .ico-close, .menubtn .ico-menu { display: contents; }

/* ---------------- переключатель темы — .themepick кабинета (shell.css) ----------------
   Стоит в самом низу меню (у кабинета его туда переносит sidebar.js) и раскрывается вправо
   рядом с кнопкой: внизу экрана ему некуда, ряд из трёх значков читается продолжением кнопки. */
.themepick { position: relative; flex: none; --themepick-w: 34px; }
.themepick-btn { width: var(--themepick-w); height: var(--themepick-w); }
.themepick-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.themepick-cur { display: grid; place-items: center; }
.themepick-cur svg { width: 17px; height: 17px; }
.themepick-list {
  position: absolute; z-index: 55;
  top: calc(100% + var(--pop-gap, 6px));
  left: 50%; transform: translateX(-50%);
  width: var(--themepick-w); padding: 3px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-pop);
}
.themepick-list[hidden] { display: none; }
.themepick-list button {
  display: grid; place-items: center;
  width: 100%; height: 26px; padding: 0;
  border: 0; border-radius: 9px; background: none;
  color: var(--muted); font: inherit; cursor: pointer;
}
.themepick-list button:hover { color: var(--ink); background: var(--surface-2); }
.themepick-list button[aria-checked="true"] { background: var(--surface-2); color: var(--ink); }
.themepick-list button svg { width: 16px; height: 16px; }
.side > .themepick { margin-top: auto; padding-top: 12px; align-self: flex-start; }
.side > .themepick .themepick-btn {
  width: var(--themepick-w); border-color: transparent; background: transparent;
  color: var(--muted);
}
.side > .themepick .themepick-btn:hover { background: var(--surface-2); color: var(--ink); }
.side > .themepick .themepick-list {
  top: 12px; bottom: auto; left: calc(100% + 6px); right: auto;
  width: auto; height: var(--themepick-w); box-sizing: border-box;
  transform: none; flex-direction: row; align-items: stretch;
}
.side > .themepick .themepick-list button { width: 32px; height: auto; }
html[data-side="mini"] .side > .themepick { align-self: center; }
/* Подвал меню идёт под переключателем, а не делит с ним пустоту поровну. */
.side > .themepick + footer { margin-top: 10px; }
.navgroup > span {
  display: block; padding: 0 8px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.side a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
}
.side a > svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side a > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a:hover { background: var(--surface-2); color: var(--ink); }
.side a[aria-current] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.side a[aria-current] > svg { opacity: 1; }
.side footer {
  margin-top: auto; padding: 12px 8px 2px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
}

/* ---------------- шапка ---------------- */

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 20px; height: var(--top-h);
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 40;
  --pop-gap: calc((var(--top-h) - 34px) / 2 + 6px);
}
.brandmark {
  display: flex; align-items: center; gap: 9px; flex: 0 1 auto; min-width: 0;
  color: var(--ink); text-decoration: none; font-weight: 650; font-size: 15px; letter-spacing: -.01em;
}
/* Логотип — icons/icon-192.png: прозрачные скруглённые углы уже в самом файле. Прежний logo.png нёс
   белую рамку в 4 пикселя прямо в картинке — она и была «белым кольцом». Ни фона, ни рамки, ни
   скругления поверх: они только добавили бы ободок. */
.brandmark img { width: 32px; height: 32px; display: block; flex: none; border: 0; background: none; box-shadow: none; border-radius: 0; }
.brandmark span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.icobtn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icobtn:hover { background: var(--surface-2); color: var(--ink); }
.icobtn svg { width: 17px; height: 17px; }
.menubtn { display: none; }

/* Меню пользователя: кнопка-аватар, под ней кто вошёл и выход.
   details/summary вместо JS-меню кабинета; закрытие по щелчку мимо — app.js. */
.usermenu { position: relative; }
.usermenu > summary { list-style: none; cursor: pointer; border-radius: var(--r-sm); display: block; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu .ava {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex: none;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 650; text-transform: uppercase;
  overflow: hidden;
}
.usermenu > summary:hover .ava, .usermenu[open] > summary .ava { border-color: var(--muted); color: var(--ink); }
.usermenu-list {
  position: absolute; top: calc(100% + var(--pop-gap, 6px)); right: 0; z-index: 55;
  min-width: 208px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 2px;
}
.usermenu-head { padding: 6px 10px 8px; display: flex; flex-direction: column; }
.usermenu-head b { font-size: 13.5px; font-weight: 650; overflow-wrap: anywhere; }
.usermenu-head small { font-size: 12px; color: var(--muted); }
.usermenu-list form { margin: 0; }
.usermenu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); text-decoration: none;
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.usermenu-item svg { width: 16px; height: 16px; flex: none; }
.usermenu-item:hover { background: var(--surface-2); }
.usermenu-item.separated { margin-top: 5px; padding-top: 11px; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-sm) var(--r-sm); }
.usermenu-item.danger { color: var(--crit); }
.usermenu-item.danger:hover { background: var(--crit-soft); }

/* ---------------- рабочая область ---------------- */

.main { padding: 14px 20px 28px; min-width: 0; flex: 1; }

/* Карточка — .panel кабинета: поверхность, волосяная рамка, без тени.
   Внутренние поля здесь у самой карточки: в кабинете их задают разделы. */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin: 0 0 16px; min-width: 0;
}
.card > :last-child { margin-bottom: 0; }
.card p { margin: 0 0 10px; }
.center { text-align: center; }
.code { font-size: 44px; font-weight: 700; letter-spacing: -.03em; color: var(--link); line-height: 1.1; margin-bottom: 8px; }
.lead { font-size: 15px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-between h2 { margin: 0; }
.card > .row-between { margin-bottom: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .btn { align-self: flex-start; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------------- заметки (баннеры) — .note кабинета ---------------- */

.banner, p.warn {
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 9px 12px; margin: 0 0 14px;
  font-size: 13px; overflow-wrap: anywhere;
}
.banner.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.banner.warn, p.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.banner.error { border-left-color: var(--crit); background: var(--crit-soft); }
.banner a { color: var(--link); font-weight: 600; }

/* ---------------- плитки — .simtile кабинета ---------------- */

.tiles {
  display: grid; gap: 10px; margin: 0 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card .tiles { margin-bottom: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 13px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.card .tile { background: var(--surface-2); }
.tile .num, .tile strong {
  order: 2; font-size: 24px; font-weight: 650; color: var(--ink);
  text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.tile.alert { box-shadow: inset 3px 0 0 var(--warn); }

.servers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.srv {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 13px;
  display: flex; flex-direction: column; gap: 2px; background: var(--surface-2); min-width: 0;
}
.srv b { font-weight: 650; }
.srv small { font-size: 12px; overflow-wrap: anywhere; }
.srv small.mono { font-size: 11.5px; }
.srv.off { opacity: .55; }

/* ---------------- поля — .fld кабинета ----------------
   Подпись — текст самой label, поле внутри неё: так размечены шаблоны,
   и разметку ради оформления не трогаем. */
label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  min-height: 38px; padding: 8px 11px; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--link); }
input[readonly], textarea[readonly] { background: var(--surface-2); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea.conf { width: 100%; white-space: pre; overflow: auto; font-size: 12px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.inline-form:last-child { margin-bottom: 0; }
.inline-form input[name=value] { flex: 1 1 220px; }
.inline-form input[name=comment] { flex: 1 1 180px; }
.inline-form input[name=login], .inline-form input[name=password], .inline-form input[name=ip] { flex: 1 1 180px; }
.inline-form.compact { margin: 0; flex-wrap: nowrap; gap: 6px; }
.inline-form.compact input { width: 150px; min-height: 28px; height: 28px; padding: 0 9px; font-size: 12.5px; flex: none; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form > .btn { justify-self: start; }
.issue-form { max-width: 560px; }

/* Выбор режима — две плашки-варианта; выбранная обведена фирменным цветом. */
fieldset.modes {
  border: 0; padding: 0; margin: 0; min-width: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px;
}
fieldset.modes legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 6px; }
label.radio {
  flex-direction: row; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font-size: 13.5px; cursor: pointer;
}
label.radio:hover { border-color: var(--muted); }
label.radio:has(input:checked) { border-color: var(--link); background: var(--brand-soft); }
label.radio input { min-height: 0; margin: 3px 0 0; accent-color: var(--link); flex: none; }
label.radio span { display: flex; flex-direction: column; gap: 1px; }
label.radio b { font-weight: 600; }
label.radio small { color: var(--muted); font-size: 12px; }

/* ---------------- кнопки — .btn кабинета ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary, .btn.period-active {
  background: var(--brand-fill, var(--brand)); border-color: var(--brand-edge, var(--brand));
  color: var(--on-fill, var(--on-brand)); font-weight: 600;
}
.btn.primary:hover, .btn.period-active:hover { filter: brightness(.95); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- статусы — .pill кабинета ---------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.suspect, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.revoked { background: var(--crit-soft); color: var(--crit); }
.pill.provisioning, .pill.unblocking, .pill.unknown { background: var(--info-soft); color: var(--info); }

/* ---------------- таблицы — table.css кабинета ---------------- */

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.card > .table-wrap:first-child { margin-top: -6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
tbody td.wrap { white-space: normal; min-width: 200px; overflow-wrap: anywhere; }
tbody tr:hover { background: var(--ground); }
tbody tr:last-child td { border-bottom: 0; }
tr.dim td { opacity: .55; }
tr.sub td { padding-top: 0; white-space: normal; }
tr:has(+ tr.sub) td { border-bottom: 0; }
td.actions { text-align: right; }
td.actions > form { display: inline-flex; margin: 2px 0 2px 4px; vertical-align: middle; }
td[colspan].muted { text-align: center; padding: 28px 10px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.periods { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }

/* ---------------- профиль ---------------- */

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 4px 0 14px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.profile-card form { margin: 0 0 10px; }
.qr { width: 100%; max-width: 320px; border-radius: var(--r-sm); background: #fff; padding: 8px; image-rendering: pixelated; display: block; border: 1px solid var(--line); }

/* ---------------- график трафика ---------------- */

svg.chart { width: 100%; height: 180px; display: block; margin-bottom: 8px; }
.bar-rx { fill: var(--brand); }
.bar-tx { fill: var(--info); opacity: .75; }
.chart-label { fill: var(--muted); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.key-rx { background: var(--brand); }
.key-tx { background: var(--info); opacity: .75; }

/* ---------------- вход — экран .login кабинета ---------------- */

.login {
  min-height: 100vh; padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.login > .banner { width: min(380px, 100%); margin: 0; }
.loginbox, .login > .card {
  width: min(380px, 100%); margin: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 26px 24px;
}
.login > .card { width: min(460px, 100%); }
.loginbox { display: flex; flex-direction: column; gap: 14px; }
.loginbox .head { display: flex; align-items: center; gap: 12px; padding-bottom: 2px; }
.loginbox .head img { width: 44px; height: 44px; display: block; flex: none; border: 0; background: none; box-shadow: none; border-radius: 0; }
.loginbox .head h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.loginbox .head small { font-size: 12px; color: var(--muted); }
.loginbox form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.loginbox form .banner { margin: 0; }
.loginbox input { width: 100%; }
.loginbox .btn { height: 40px; width: 100%; }
.loginbox p { margin: 0; font-size: 13px; }

/* ---------------- прелоадеры — shell.css кабинета ----------------
   Два вида, как у кабинета:
   .bootscreen — экран загрузки: стоит в разметке первым узлом body и виден с
     первого кадра, пока страница не готова; app.js гасит его не раньше
     MIN_SHOW_MS (450) от начала загрузки и уводит за --fade-shell (.28s).
   .loader — накладка на время перехода: ссылка меню, отправка формы. app.js
     показывает её через 160 мс (короткий переход проходит без вспышки).
   Навсегда не перекрывают ничего: без JS их прячет noscript.css, при сбое
   скрипта — страховочная анимация (8 с), у экрана загрузки ещё и
   pointer-events: none.
   ⚠️ Подложка обоих — глухой цвет фона темы (--ground), без прозрачности и
   размытия: так попросил владелец, сквозь прелоадер не должно быть видно
   страницы. И текста в них нет вовсе — только точки; скринридеру прелоадер
   называют aria-busy и aria-label на контейнере. */

.pdots { display: flex; gap: 8px; }
.pdots i {
  display: block; width: 14px; height: 14px; flex: none;
  border-radius: 999px; background: var(--dot-color);
  transform: scale(0);
  animation: dotpulse var(--dot-pulse) ease-in-out infinite;
}
.pdots i:nth-child(2) { animation-delay: calc(var(--dot-pulse) * -0.25); }
.pdots i:nth-child(3) { animation-delay: calc(var(--dot-pulse) * -0.5); }
@keyframes dotpulse { 50% { transform: scale(1); } }

.bootscreen {
  position: fixed; inset: 0; z-index: 65;
  display: grid; place-items: center; align-content: center;
  padding: 24px; pointer-events: none;
  background: var(--ground);
  opacity: 0; transition: opacity var(--fade-shell);
  /* Страховка: что бы ни случилось со скриптом, через 8 с экран уходит сам. */
  animation: preload-safety .28s ease-out 8s forwards;
}
.bootscreen[data-phase="in"] { opacity: 1; }
.bootart { gap: 10px; }
.bootart i { width: 22px; height: 22px; }

.loader {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; align-content: center;
  background: var(--ground);
  animation: preload-safety .28s ease-out 8s forwards;
}
@keyframes preload-safety { to { opacity: 0; visibility: hidden; } }

@media (max-width: 640px) {
  .bootart { gap: 8px; }
  .bootart i { width: 17px; height: 17px; }
}
/* Меньше движения: точки стоят, а не мигают (tokens.css сжимает анимации до
   0.01 мс, и пульс превратился бы в мерцание). Затухание — мгновенно. */
@media (prefers-reduced-motion: reduce) {
  .pdots i { animation: none; transform: scale(.75); }
  .bootscreen { transition: none; }
}

/* ---------------- свёрнутое меню: полоса значков (shell.css кабинета) ----------------
   Только там, где сайдбар стоит колонкой (>=901px). Состояние — data-side на <html> (boot.js до
   отрисовки, app.js по кнопке). Наведение раскрывает не панель, а подпись одного пункта. */
@media (min-width: 901px) {
  html[data-side="mini"] .app { grid-template-columns: var(--side-w-mini) minmax(0, 1fr); }
  html[data-side="mini"] .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 41; height: auto;
    width: var(--side-w-mini); overflow: visible;
    padding-left: 8px; padding-right: 8px;
  }
  html[data-side="mini"] .side .navgroup > span,
  html[data-side="mini"] .side footer { display: none; }
  html[data-side="mini"] .side a { position: relative; justify-content: center; padding: 9px 0; }
  html[data-side="mini"] .sidehead { justify-content: center; padding-bottom: 22px; }
  html[data-side="mini"] .sidehead + .navgroup { margin-top: 0; }
  html[data-side="mini"] .side a > span {
    display: none;
    position: absolute; left: 100%; top: 0; bottom: 0; margin-left: -2px;
    align-items: center; padding: 0 14px;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--surface-2); color: var(--ink);
    box-shadow: var(--shadow-pop);
    white-space: nowrap; font-size: 13.5px; overflow: visible;
  }
  html[data-side="mini"] .side a:hover > span,
  html[data-side="mini"] .side a:focus-visible > span {
    display: flex;
    animation: navlabel .09s cubic-bezier(.22, 1, .36, 1);
  }
  @keyframes navlabel {
    from { opacity: 0; transform: translateX(-5px); }
    to   { opacity: 1; transform: none; }
  }
  html[data-side="mini"] .side a:hover,
  html[data-side="mini"] .side a:focus-visible { border-radius: var(--r-sm) 0 0 var(--r-sm); }
  html[data-side="mini"] .side .navgroup + .navgroup {
    margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
  }
}

/* ---------------- адаптив ---------------- */

.backdrop { display: none; }

/* Сайдбар на узком экране — выдвижная шторка, как у кабинета: без неё
   разделы были бы недостижимы с телефона. Открывает её флажок .navtoggle. */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .pane { grid-column: 1; }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; height: auto; width: min(280px, 84vw);
    z-index: 50; transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease-out, visibility 0s linear .22s;
    box-shadow: var(--shadow-pop);
  }
  .navtoggle:checked ~ .side { transform: none; visibility: visible; transition: transform .22s ease-out; }
  .backdrop {
    display: block; position: fixed; inset: 0; z-index: 45;
    background: rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; transition: opacity .22s ease-out;
  }
  .navtoggle:checked ~ .backdrop { opacity: 1; pointer-events: auto; }
  /* Шторка под пальцем (app.js, перенос drawer-swipe.js): положение задаёт жест через --drawer-x,
     переходы выключены, иначе шторка догоняла бы палец с задержкой. */
  body[data-drawer-swipe="1"] .side {
    transform: translate3d(var(--drawer-x, -100%), 0, 0);
    transition: none; visibility: visible;
  }
  body[data-drawer-swipe="1"] .backdrop { transition: none; }
  .sidehead { display: none; }
  .side { touch-action: pan-y; overscroll-behavior: contain; overflow-y: auto; }
  /* В шторке список темы открывается вверх-вправо внутри неё: за край шторки уходить некуда. */
  .side > .themepick .themepick-list { left: calc(var(--themepick-w) + 6px); }
  .themepick { --themepick-w: 38px; }
  .themepick-list button { height: 32px; }
  .navtoggle:focus-visible ~ .pane .menubtn { box-shadow: var(--focus-ring); }
  .menubtn { display: grid; }
  .top { gap: 10px; padding: 0 12px; }
  .main { padding: 14px 16px 24px; }
  .icobtn, .usermenu .ava { width: 38px; height: 38px; }
  .side a { padding: 11px 8px; }
  .navgroup:first-child, .sidehead + .navgroup, html:not(.js) .sidehead + .navgroup { margin-top: 4px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .facts dd { margin-bottom: 6px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .num, .tile strong { font-size: 20px; }
  .inline-form > input, .inline-form > select { flex: 1 1 100%; }
  .inline-form > .btn { flex: 1 1 auto; }
  .inline-form.compact > input { flex: 1 1 120px; width: auto; }
  .loginbox { padding: 22px 18px; }
}
