/* ===========================================================================
   Карлтон-Бэй, дело 51-1027

   Две поверхности, и они не должны смешиваться:

   1. ИНТЕРФЕЙС — чёрный хром. Чёрный и графит, мягкие радиальные градиенты,
      широкий гротеск капсом в заголовках, волосяные линии, пиксельные значки.
      Цвета нет: белый, серые и хром. Красный и зелёный — только состояния.
   2. БУМАГА — документы дела. Пожелтевший лист, засечки, поля, чернила.
      Игрок читает документ, а не интерфейс.

   Живой фон (каркасные волны, окружности) рисует /js/ui.js, хромовую каплю —
   /js/blob.js. Без них страница остаётся целой: это оформление, не механика.

   Шрифты грузятся из Google Fonts, у каждого есть системный запасной.
   Unbounded выбран за кириллицу: латинские аналоги из референса её не имеют.
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;400;500&family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Crimson+Pro:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  /* --- интерфейс: ступени от чёрного к серому, как колонки в референсе --- */
  --bg: #050505;
  --g0: #0a0a0b;             /* чёрная панель */
  --g1: #151517;
  --g2: #232427;             /* графит */
  --g3: #3a3b3f;
  --g4: #4f5054;             /* светло-серая панель */

  --bg-panel: rgba(14, 14, 16, 0.86);
  --bg-input: rgba(255, 255, 255, 0.025);
  --bg-hover: rgba(255, 255, 255, 0.06);

  --panel-black: radial-gradient(120% 90% at 30% 0%, #1b1b1d 0%, #0b0b0c 55%, #060606 100%);
  --panel-graphite: linear-gradient(180deg, #2c2d30 0%, #1a1b1d 100%);
  --panel-grey: linear-gradient(180deg, #56575b 0%, #3e3f43 100%);

  --accent: #ffffff;         /* заголовки, значения, активное */
  --accent-soft: #d6d6d6;    /* второстепенный акцент */
  --accent-dim: #5e5f63;     /* только рамки, не текст */

  --text: #e4e4e4;           /* основной текст, 15:1 к фону */
  --text-dim: #9d9d9d;       /* подписи и метки, 7:1 к фону */

  --line: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.55);

  --danger: #e5806c;         /* 6.9:1 — предупреждения читаемы */
  --ok: #b7cf98;             /* 11:1 */

  /* --- бумага --- */
  --paper: #ddd2bb;
  --paper-edge: #c8bb9f;
  --ink: #241e14;
  --ink-soft: #55482f;
  --paper-line: #8a7a5c;

  /* --- шрифты --- */
  --display: "Unbounded", "Arial Black", "Segoe UI", sans-serif;
  --sans: "Manrope", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Courier New", "DejaVu Sans Mono", Consolas, monospace;
  --serif: "Crimson Pro", Georgia, "Times New Roman", serif;

  /* --- плотность --- */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --tap: 44px;               /* минимальная зона нажатия */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* пиксельный значок 6×3: четыре кадра для мерцания */
  --px-a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' shape-rendering='crispEdges' fill='%23dcdcdc'%3E%3Cpath d='M.08.08h.84v.84H.08zM2.08.08h1.84v.84H2.08zM5.08.08h.84v.84h-.84zM1.08 1.08h.84v.84h-.84zM4.08 1.08h.84v.84h-.84zM.08 2.08h.84v.84H.08zM2.08 2.08h1.84v.84H2.08zM5.08 2.08h.84v.84h-.84z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

/* hidden должен скрывать всегда: иначе .gate { display: flex } и подобные
   правила перебивают его, и экран входа остаётся поверх админки */
[hidden] { display: none !important; }

html {
  background: var(--bg);
  scrollbar-color: #3d3e42 transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Фон рисуется слоем .bg позади всего. Без скрипта остаётся градиент. */
body {
  background:
    radial-gradient(90% 60% at 10% 0%, #1a1a1c 0%, transparent 60%),
    radial-gradient(70% 50% at 100% 100%, #141416 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body.has-bg { background: transparent; }

::selection { background: #fff; color: #000; }

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

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--s3);
  line-height: 1.15;
}
h1 { font-size: clamp(24px, 3.2vw, 40px); font-weight: 300; }
h2 { font-size: 17px; }
h3 { font-size: 13px; }

code { font-family: var(--mono); font-size: 0.92em; color: var(--accent-soft); }

.muted { color: var(--text-dim); }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Видимый фокус обязателен: играют с клавиатуры не реже, чем мышью. */
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* ===========================================================================
   Живой фон
   =========================================================================== */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
}
.bg-glow.g1 {
  width: 70vmax; height: 55vmax;
  left: -18vmax; top: -24vmax;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.085), transparent);
  animation: glow-a 38s ease-in-out infinite alternate;
}
.bg-glow.g2 {
  width: 60vmax; height: 50vmax;
  right: -20vmax; bottom: -26vmax;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.06), transparent);
  animation: glow-b 46s ease-in-out infinite alternate;
}

/* Большие тонкие окружности, как на панелях референса. Медленно дрейфуют. */
.bg-ring {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 50%;
  will-change: transform;
}
.bg-ring.r1 { width: 62vmin; height: 62vmin; left: 6vw; top: 8vh; animation: ring-a 60s ease-in-out infinite alternate; }
.bg-ring.r2 { width: 78vmin; height: 78vmin; right: -12vmin; top: -18vmin; animation: ring-b 72s ease-in-out infinite alternate; }
.bg-ring.r3 { width: 44vmin; height: 44vmin; right: 18vw; bottom: -14vmin; animation: ring-a 54s ease-in-out infinite alternate-reverse; }

/* Волосяные оси: горизонт и вертикаль, как сетка первого экрана. */
.bg-axis { position: absolute; background: rgba(255, 255, 255, 0.05); }
.bg-axis.h { left: 0; right: 0; top: 58%; height: 1px; }
.bg-axis.v { top: 0; bottom: 0; left: 50%; width: 1px; }

.bg-mesh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: var(--mesh-opacity, 0.7);
}
body[data-bg="quiet"] { --mesh-opacity: 0.4; }

@keyframes glow-a { to { transform: translate(14vmax, 10vmax) scale(1.1); } }
@keyframes glow-b { to { transform: translate(-12vmax, -8vmax) scale(1.15); } }
@keyframes ring-a { to { transform: translate(5vmin, -4vmin) scale(1.06); } }
@keyframes ring-b { to { transform: translate(-6vmin, 5vmin) scale(0.95); } }

/* ===========================================================================
   Пиксельный значок и линии
   =========================================================================== */

.px,
.stamp::before,
.subhead::after,
.panel > h2:first-child::after,
.modal > h2:first-child::after,
.frame-line::before,
.frame-line::after {
  content: "";
  display: inline-block;
  width: 30px;
  height: 15px;
  flex: 0 0 auto;
  background: var(--px-a) center / 100% 100% no-repeat;
  image-rendering: pixelated;
  animation: px-flicker 4.2s steps(1, end) infinite;
}

.px:nth-of-type(2n),
.panel:nth-child(2n) > h2::after { animation-delay: -1.3s; animation-duration: 5.1s; }
.px:nth-of-type(3n),
.panel:nth-child(3n) > h2::after { animation-delay: -2.7s; animation-duration: 3.7s; }

/* при наведении на владельца значок «оживает» быстрее */
:hover > .px,
.stamp:hover::before,
.panel:hover > h2:first-child::after,
.subhead:hover::after { animation-duration: 0.9s; }

/* Кадры: базовый узор держится большую часть цикла, потом клетки перебегают. */
@keyframes px-flicker {
  0%, 60% { background-image: var(--px-a); }
  64% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' shape-rendering='crispEdges' fill='%23dcdcdc'%3E%3Cpath d='M1.08.08h.84v.84h-.84zM4.08.08h.84v.84h-.84zM.08 1.08h.84v.84H.08zM2.08 1.08h1.84v.84H2.08zM5.08 1.08h.84v.84h-.84zM1.08 2.08h.84v.84h-.84zM4.08 2.08h.84v.84h-.84z'/%3E%3C/svg%3E"); }
  70% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' shape-rendering='crispEdges' fill='%23dcdcdc'%3E%3Cpath d='M.08.08h.84v.84H.08zM3.08.08h.84v.84h-.84zM5.08.08h.84v.84h-.84zM1.08 1.08h1.84v.84H1.08zM4.08 1.08h.84v.84h-.84zM.08 2.08h.84v.84H.08zM2.08 2.08h.84v.84h-.84zM5.08 2.08h.84v.84h-.84z'/%3E%3C/svg%3E"); }
  76% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' shape-rendering='crispEdges' fill='%23dcdcdc'%3E%3Cpath d='M1.08.08h1.84v.84H1.08zM4.08.08h.84v.84h-.84zM.08 1.08h.84v.84H.08zM3.08 1.08h.84v.84h-.84zM5.08 1.08h.84v.84h-.84zM1.08 2.08h.84v.84h-.84zM3.08 2.08h1.84v.84H3.08z'/%3E%3C/svg%3E"); }
  82% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' shape-rendering='crispEdges' fill='%23dcdcdc'%3E%3Cpath d='M1.08.08h.84v.84h-.84zM4.08.08h.84v.84h-.84zM.08 1.08h.84v.84H.08zM2.08 1.08h1.84v.84H2.08zM5.08 1.08h.84v.84h-.84zM1.08 2.08h.84v.84h-.84zM4.08 2.08h.84v.84h-.84z'/%3E%3C/svg%3E"); }
  88%, 100% { background-image: var(--px-a); }
}

/* Линия с двумя значками на концах — разделитель первого экрана. */
.frame-line {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: var(--s2);
}
.frame-line::before { margin-bottom: 0; }
.frame-line > span {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--line-strong);
  transform-origin: left;
  animation: draw 1.2s var(--ease) both 0.2s;
}

@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Мелкая навигация капсом по верхнему краю панели (MEASURE / ANALYZE / …). */
.frame-top {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ===========================================================================
   Появление: панели выезжают, линии прорисовываются слева направо.
   Задержку для лесенки ставит ui.js через --d.
   =========================================================================== */

.panel, .gate-box, .card, .hit, .action, .event, .thought, .paper, .role,
.asset, .rec, .modal, .granted, .log-line, .note, .reveal {
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--d, 0) * 55ms);
}

/* translate, а не transform: так наведение (transform) не спорит с появлением */
@keyframes rise {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===========================================================================
   Штамп — подпись капсом с пиксельным значком
   =========================================================================== */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  color: var(--accent-soft);
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.2em;
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: var(--s5);
}
.stamp::before { width: 24px; height: 12px; }

.case-no {
  font-family: var(--display);
  font-size: 34px;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin: 0 0 var(--s1);
}

/* ===========================================================================
   Экран ввода: служебные входы (админка, контент)
   =========================================================================== */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5) var(--s4);
}

.gate-box {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--panel-black);
  border: 1px solid var(--line-soft);
  padding: var(--s6) var(--s5);
  overflow: hidden;
}
.gate-box::after {
  content: "";
  position: absolute;
  width: 260px; height: 260px;
  right: -110px; top: -120px;
  border: 1px solid var(--line);
  border-radius: 50%;
  pointer-events: none;
}
.gate-box h1 { font-size: clamp(17px, 4.4vw, 21px); margin-bottom: var(--s5); overflow-wrap: anywhere; }

/* ===========================================================================
   Элементы формы
   =========================================================================== */

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: var(--s1);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-input);
  border: none;
  border-bottom: 1px solid var(--line-strong);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px var(--s3);
  border-radius: 0;
  outline: none;
  transition: border-color 200ms linear, background-color 200ms linear, box-shadow 200ms linear;
}

input:hover, select:hover, textarea:hover { background: rgba(255, 255, 255, 0.045); }
input:focus, select:focus, textarea:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
  background: rgba(255, 255, 255, 0.05);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
::placeholder { color: #6a6a6e; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23bbb'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 6px;
  cursor: pointer;
}
select option { background: #111113; color: var(--text); }
/* заголовки групп в списке («Улики», «Документы архива»): по умолчанию белая плашка с белым текстом */
select optgroup { background: #1d1d20; color: var(--text-dim); font-style: normal; font-weight: 600; }

input.serial-input {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.16em;
  text-align: center;
  color: var(--accent);
}

button, a.button {
  position: relative;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  min-height: var(--tap);
  padding: 10px var(--s5);
  border-radius: 0;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: color 260ms var(--ease), border-color 260ms var(--ease);
}
/* заливка выезжает слева: кнопка становится белой плашкой */
button::before, a.button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms var(--ease);
}
button:hover:not(:disabled), a.button:hover { color: #000; border-color: var(--accent); }
button:hover:not(:disabled)::before, a.button:hover::before { transform: scaleX(1); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.35; cursor: default; }
button.wide { width: 100%; }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); }
button.primary::before { background: #cfcfcf; }
button.small, a.button.small { min-height: 32px; padding: var(--s1) var(--s3); font-size: 11px; letter-spacing: 0.12em; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger::before { background: var(--danger); }
button.danger:hover:not(:disabled) { color: #000; border-color: var(--danger); }

.field { margin-bottom: var(--s4); }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.row > .shrink { flex: 0 0 auto; }

.message { margin-top: var(--s4); min-height: 20px; font-size: 14px; }

/* ===========================================================================
   Бумага: документы дела (не меняется вместе с интерфейсом)
   =========================================================================== */

.paper {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-edge);
  padding: var(--s6) clamp(var(--s4), 5vw, 40px);
  margin: var(--s3) 0 var(--s5);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  /* затемнение по краям: лист лежит, а не наклеен */
  box-shadow:
    inset 0 0 80px rgba(120, 100, 70, 0.22),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

.paper pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--ink);
}

.paper h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  margin: 0 0 var(--s1);
}

.paper .dateline {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 var(--s4);
  font-size: 14px;
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: var(--s2);
}

.paper .letterhead {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  padding-bottom: var(--s2);
  margin-bottom: var(--s4);
}

.paper .signature {
  margin-top: var(--s5);
  text-align: right;
  font-style: italic;
}

.paper p { margin: 0 0 var(--s3); }
.paper p:last-child { margin-bottom: 0; }

.paper img {
  max-width: 100%;
  display: block;
  margin: 0 0 var(--s4);
  border: 1px solid var(--paper-line);
}

/* ===========================================================================
   Панели, подзаголовки
   =========================================================================== */

.panel {
  position: relative;
  background: var(--panel-black);
  border: 1px solid var(--line-soft);
  padding: var(--s5);
  margin-bottom: var(--s4);
}

/* заголовок панели: текст, линия под ним и значок на правом конце */
.panel > h2:first-child,
.modal > h2:first-child {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
  padding-bottom: var(--s3);
  margin-bottom: var(--s4);
}
.panel > h2:first-child::after,
.modal > h2:first-child::after { width: 24px; height: 12px; margin: 0 0 3px auto; }
.panel > h2:first-child::before,
.modal > h2:first-child::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--line);
  transform-origin: left;
  animation: draw 1s var(--ease) both 0.15s;
}

.subhead {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: var(--s2);
  margin-top: var(--s6);
  margin-bottom: var(--s3);
}
.subhead::after { width: 24px; height: 12px; }
.subhead::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--line);
  transform-origin: left;
  animation: draw 1s var(--ease) both;
}

/* ===========================================================================
   Служебные страницы: админка, изображения, контент
   =========================================================================== */

.admin-top {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 6, 7, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: var(--s3) var(--s5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
}
.admin-top .stamp { color: var(--accent); }
.admin-top a { text-decoration: none; }
.admin-top .row > * { flex: 0 0 auto; }

.admin-body { padding: var(--s5); max-width: 1200px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px var(--s2); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  border-bottom-color: var(--line-strong);
}
tbody tr { transition: background-color 160ms linear; }
tbody tr:hover { background: var(--bg-hover); }

.tag {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tag-unused { color: var(--text-dim); }
.tag-active { color: #000; background: var(--accent); border-color: var(--accent); }
.tag-completed { color: var(--ok); border-color: var(--ok); }
.tag-revoked { color: var(--danger); border-color: var(--danger); }

/* Крупные цифры: число, под ним линия и подпись — как 22% / 35% в референсе. */
.stats { display: flex; gap: var(--s6); flex-wrap: wrap; }
.stats > div { min-width: 120px; }
.stat-num {
  font-family: var(--display);
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 400;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  position: relative;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: var(--s2);
  padding-top: var(--s2);
}
.stat-label::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: var(--line-strong);
  transform-origin: left;
  animation: draw 1s var(--ease) both 0.1s;
}

/* ===========================================================================
   Модальные окна
   =========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  z-index: 20;
  animation: fade 0.35s linear both;
}
.overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel-black);
  padding: var(--s5) var(--s5) var(--s5);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.keys {
  background: var(--bg-input);
  border: 1px solid var(--line);
  padding: var(--s3);
  max-height: 300px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--accent);
  white-space: pre;
}

.warn {
  border-left: 2px solid var(--danger);
  padding-left: var(--s3);
  color: var(--danger);
  margin: var(--s3) 0;
  font-size: 13px;
}

/* ===========================================================================
   Доступность
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 640px) {
  .admin-top { padding: var(--s2) var(--s3); }
  .admin-body { padding: var(--s3); }
  .panel { padding: var(--s4); }
  .gate-box { padding: var(--s5) var(--s4); }
  table { font-size: 12px; }
  .hide-narrow { display: none; }
  .paper { padding: var(--s5) var(--s4); font-size: 16px; }
  .paper pre { font-size: 12px; }
  .stats { gap: var(--s5); }
  .stats > div { min-width: 100px; }
  input.serial-input { font-size: 17px; letter-spacing: 0.08em; padding-left: 6px; padding-right: 6px; }
}
