/* =========================================================================
   Портал «Места» — визуальная система

   Один слой токенов задаёт цвет, типографику, радиусы и тени; светлая и
   тёмная схемы отличаются только значениями токенов. Правила ниже токены
   используют, но не переопределяют цвета вручную.
   ========================================================================= */

:root {
  color-scheme: light;

  /* Поверхности и текст */
  --bg: #f3f1ec;
  --surface: #fbfaf7;
  --surface-sunken: #efece5;
  --surface-hover: #f4f2ec;
  /* Три уровня текста подобраны расчётом контрастности, а не на глаз:
     ГОСТ Р 52872-2019 требует 4.5:1, а прежний --text-faint давал 2.6:1
     на заголовках таблиц и метках. Уровни разведены с запасом, чтобы
     иерархия оставалась различимой и не зависела от округления в браузере. */
  --text: #1b201f;
  --text-muted: #4d5451;
  --text-faint: #626967;
  --border: #dcdad1;
  /* Граница интерактивных элементов: единственный признак, по которому
     опознаётся пустое поле ввода, поэтому обязана давать 3:1 (WCAG 1.4.11). */
  --border-strong: #939189;

  /* Акцент и семантика: приглушённые, без пастельной подсветки */
  --accent: #0f5344;
  --accent-hover: #0b4235;
  --accent-on: #ffffff;
  --accent-tint: rgba(15, 83, 68, 0.09);
  --accent-line: rgba(15, 83, 68, 0.22);

  --ok: #1f6b52;
  --ok-tint: rgba(31, 107, 82, 0.1);
  --warn: #7d5810;
  --warn-tint: rgba(170, 126, 34, 0.14);
  --risk: #9a3f2f;
  --risk-tint: rgba(154, 63, 47, 0.11);
  --idle: #626967;
  --idle-tint: rgba(107, 115, 112, 0.1);

  /* Типографика */
  --font-ui: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --fs-label: 0.6875rem;   /* 11 */
  --fs-xs: 0.75rem;        /* 12 */
  --fs-sm: 0.8125rem;      /* 13 */
  --fs-md: 0.875rem;       /* 14 */
  --fs-h2: 1.0625rem;      /* 17 */
  --fs-h1: 1.625rem;       /* 26 */
  --fs-stat: 1.5rem;       /* 24 */

  /* Ритм, форма, глубина */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(20, 25, 23, 0.05);
  --shadow-2: 0 10px 30px -12px rgba(20, 25, 23, 0.22);
  --shadow-3: 0 24px 60px -16px rgba(20, 25, 23, 0.32);
  --sidebar-w: 232px;
  --gutter: clamp(16px, 3vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14181a;
    --surface: #1a1f21;
    --surface-sunken: #21272a;
    --surface-hover: #222829;
    --text: #e7eae8;
    --text-muted: #98a19e;
    --text-faint: #8a928f;
    --border: #2b3235;
    --border-strong: #676d71;
    --accent: #45a389;
    --accent-hover: #4bad92;
    --accent-on: #06120f;
    --accent-tint: rgba(63, 157, 131, 0.14);
    --accent-line: rgba(63, 157, 131, 0.3);
    --ok: #57b08f;
    --ok-tint: rgba(87, 176, 143, 0.14);
    --warn: #cfa04a;
    --warn-tint: rgba(207, 160, 74, 0.15);
    --risk: #d17f6c;
    --risk-tint: rgba(209, 127, 108, 0.15);
    --idle: #98a19e;
    --idle-tint: rgba(152, 161, 158, 0.12);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-3: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181a;
  --surface: #1a1f21;
  --surface-sunken: #21272a;
  --surface-hover: #222829;
  --text: #e7eae8;
  --text-muted: #98a19e;
  --text-faint: #8a928f;
  --border: #2b3235;
  --border-strong: #676d71;
  --accent: #45a389;
  --accent-hover: #4bad92;
  --accent-on: #06120f;
  --accent-tint: rgba(63, 157, 131, 0.14);
  --accent-line: rgba(63, 157, 131, 0.3);
  --ok: #57b08f;
  --ok-tint: rgba(87, 176, 143, 0.14);
  --warn: #cfa04a;
  --warn-tint: rgba(207, 160, 74, 0.15);
  --risk: #d17f6c;
  --risk-tint: rgba(209, 127, 108, 0.15);
  --idle: #98a19e;
  --idle-tint: rgba(152, 161, 158, 0.12);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-3: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
}

/* ---------- Основа ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

/* Атрибут hidden получает display:none из таблицы браузера, а любое правило
   автора с display (например .button { display: inline-flex }) его перебивает.
   Без этой строки элемент, скрытый через element.hidden = true, остаётся
   видимым — так «Открыть ChatGPT» показывалась сотруднику без места, а кнопка
   сброса демоданных — в боевом контуре. !important здесь принятая практика. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-booting .app,
body.is-booting .topbar { visibility: hidden; }
body.no-scroll { overflow: hidden; }

h1, h2, h3, p, dl, dd, dt, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }

h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 400;
  letter-spacing: -0.012em;
  line-height: 1.15;
}

h2 {
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.006em;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

a { color: var(--accent); }

/* Числа выравниваются по разрядам — колонки в таблице не «дышат». */
.num { font-variant-numeric: tabular-nums; }

.label {
  color: var(--text-faint);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.fine {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 300;
  left: var(--sp-3);
  top: -60px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--sp-3); }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: var(--sp-5) var(--sp-3);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-2) var(--sp-6);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-on);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  line-height: 1;
}

.brand-text strong { display: block; font-size: var(--fs-md); font-weight: 600; }
.brand-text small { display: block; color: var(--text-faint); font-size: var(--fs-label); }

.nav { display: grid; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text); }
.nav-item .icon { color: var(--text-faint); }
.nav-item.is-active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.nav-item.is-active .icon { color: var(--accent); }

.sidebar-bottom { display: grid; gap: var(--sp-3); }

.cycle {
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  display: grid;
  gap: 2px;
}
.cycle strong { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.cycle-hint { color: var(--text-faint); font-size: var(--fs-label); }

.profile {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2) 0;
  border-top: 1px solid var(--border);
}
.profile-text { min-width: 0; }
.profile-text strong { display: block; font-size: var(--fs-sm); font-weight: 600; }
.profile-text small,
.drawer-person small { display: block; color: var(--text-faint); font-size: var(--fs-label); }
.profile-text strong,
.profile-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  font-size: var(--fs-label);
  font-weight: 600;
}
.avatar.lg { width: 40px; height: 40px; font-size: var(--fs-sm); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(12, 16, 15, 0.45);
}
.scrim[hidden] { display: none; }
/* Выдвижная карточка модальна, поэтому затемнение должно накрывать и сайдбар.
   Для мобильного меню затемнение наоборот остаётся под ним. */
.scrim.is-over-sidebar { z-index: 110; }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 52px;
  padding: 0 var(--gutter);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-actions { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; }

.sync {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-faint);
  font-size: var(--fs-xs);
}
.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ok);
}
.sync.is-busy .sync-dot { background: var(--warn); }
.sync.is-error .sync-dot { background: var(--risk); }
.sync.is-error { color: var(--risk); }

/* ---------- Управляющие элементы ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.button:hover { background: var(--surface-hover); border-color: var(--text-faint); }
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
}
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.wide { width: 100%; }
.button[disabled] { opacity: 0.5; cursor: default; pointer-events: none; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.ghost-button:hover { background: var(--surface-sunken); color: var(--text); }

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-sunken); color: var(--text); }

.menu-button { display: none; }

.icon-dark { display: none; }
:root[data-theme="dark"] .icon-light { display: none; }
:root[data-theme="dark"] .icon-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-light { display: none; }
  :root:not([data-theme="light"]) .icon-dark { display: block; }
}

.field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-faint);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.field input,
.field select {
  min-width: 0;
  width: 100%;
  height: 30px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
}
.field.search { width: 220px; }
.field.select { position: relative; padding-right: var(--sp-1); }
.field.select select { appearance: none; padding-right: var(--sp-4); cursor: pointer; }
.field.select .icon { position: absolute; right: var(--sp-2); pointer-events: none; }
.field input[type="search"]::-webkit-search-cancel-button { appearance: none; }

.field-block { display: grid; gap: var(--sp-2); }
.field-block > span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.field-block > input {
  width: 100%;
  height: 34px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.field-block > input:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.field-block .field { height: 34px; }
.field-block .field select { height: 32px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-actions { display: flex; justify-content: flex-end; margin-top: var(--sp-6); }

.form-error {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--risk-tint);
  color: var(--risk);
  font-size: var(--fs-xs);
}
.form-error[hidden] { display: none; }

/* ---------- Страницы ---------- */

main { flex: 1; padding: var(--sp-8) var(--gutter) 64px; }

.view { display: none; }
.view.is-active { display: grid; gap: var(--sp-4); align-content: start; }

.narrow { display: grid; gap: var(--sp-4); width: 100%; max-width: 960px; }

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}
.head .label { margin-bottom: var(--sp-2); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.panel.pad { padding: var(--sp-5); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.toolbar { display: flex; gap: var(--sp-2); }

/* Предупреждение о работе на заглушке. Занимает всю ширину и живёт над
   содержимым: его нельзя пропустить, но оно не перекрывает интерфейс. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin: 0;
  padding: var(--sp-3) var(--gutter);
  background: var(--warn-tint);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.notice[hidden] { display: none; }
.notice .icon { margin-top: 1px; color: var(--warn); }
.notice strong { font-weight: 600; }

.badge {
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Очередь действий */
.queue-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.queue-list .empty { grid-column: 1 / -1; padding: var(--sp-8) var(--sp-5); }
.task {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-4) var(--sp-5);
  border-right: 1px solid var(--border);
}
.task:last-child { border-right: 0; }
.task-top { display: flex; align-items: flex-start; gap: var(--sp-3); }
.task-top .icon { margin-top: 2px; }
.task-invite .icon { color: var(--ok); }
.task-remind .icon { color: var(--warn); }
.task-revoke .icon { color: var(--risk); }
.task strong { display: block; font-size: var(--fs-sm); font-weight: 600; }
.task small { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.task .link {
  align-self: flex-start;
  margin-top: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.task .link:hover { text-decoration: underline; }

/* Показатели */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.stat {
  display: grid;
  gap: var(--sp-2);
  align-content: start;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.stat-value {
  font-size: var(--fs-stat);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.stat-foot {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  color: var(--text-faint);
  font-size: var(--fs-xs);
}
.stat.is-alert .stat-value { color: var(--risk); }

.meter {
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.meter .meter-fill {
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}
.meter.is-warn .meter-fill { background: var(--warn); }
.meter.is-risk .meter-fill { background: var(--risk); }
.meter.thin { height: 3px; }

/* ---------- Таблицы ---------- */

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  padding: var(--sp-2) var(--sp-5);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody td {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  vertical-align: middle;
}
tbody tr:first-child td { border-top: 0; }
.registry tbody tr { cursor: pointer; }
.registry tbody tr:hover { background: var(--surface-hover); }
.col-action { text-align: right; }
td.col-action { text-align: right; white-space: nowrap; }

.person { display: flex; align-items: center; gap: var(--sp-3); min-width: 190px; }
.person strong { display: block; font-size: var(--fs-sm); font-weight: 600; }
.person small { display: block; color: var(--text-faint); font-size: var(--fs-label); }

.cell-sub { display: block; margin-top: 2px; color: var(--text-faint); font-size: var(--fs-label); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.status .dot,
.dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: currentColor;
}
.status-ok { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-risk { color: var(--risk); }
.status-idle { color: var(--idle); }

.row-action {
  padding: 4px var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.row-action:hover { border-color: var(--accent-line); background: var(--accent-tint); }
.row-action.is-quiet { color: var(--text-muted); font-weight: 500; }

.audit tbody td:first-child { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty {
  display: grid;
  gap: var(--sp-1);
  padding: 56px var(--sp-5);
  text-align: center;
  color: var(--text-muted);
}
.empty[hidden] { display: none; }
.empty strong { font-size: var(--fs-sm); color: var(--text); }
.empty span { font-size: var(--fs-xs); }

/* ---------- Кабинет сотрудника ---------- */

.access {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.access-main { padding: var(--sp-6); }
.access-status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.access-main h2 {
  margin: var(--sp-3) 0 var(--sp-1);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.access-note { color: var(--text-muted); font-size: var(--fs-sm); }
.access-main .button { margin-top: var(--sp-5); }

.access-side {
  display: grid;
  gap: var(--sp-2);
  align-content: center;
  padding: var(--sp-6);
  background: var(--surface-sunken);
  border-left: 1px solid var(--border);
}
.access-side strong { font-size: 1.125rem; font-weight: 600; }
.access-side .meter { background: var(--border-strong); }
.access-left { color: var(--text-muted); font-size: var(--fs-xs); }

.employee-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--sp-4); }

.price { display: flex; align-items: baseline; gap: var(--sp-2); margin: var(--sp-4) 0; }
.price strong { font-size: 1.75rem; font-weight: 500; letter-spacing: -0.02em; }
.price span { color: var(--text-faint); font-size: var(--fs-xs); }

.ticks { display: grid; gap: var(--sp-2); margin: 0 0 var(--sp-5); }
.ticks li {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: var(--sp-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.ticks li::before {
  content: "";
  width: 5px;
  height: 5px;
  margin: 6px 0 0 5px;
  border-radius: var(--r-pill);
  background: var(--accent);
}
.panel.pad .fine { margin-top: var(--sp-3); text-align: center; }

/* Сообщение вместо кнопки продления, когда оплата принимается вне портала. */
.manual-pay {
  padding: var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.history-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.history-row:first-child { padding-top: var(--sp-4); }
.history-row:last-child { border-bottom: 0; padding-bottom: 0; }
.history-row .icon { color: var(--ok); }
.history-row strong { display: block; font-size: var(--fs-sm); font-weight: 500; }
.history-row small { display: block; color: var(--text-faint); font-size: var(--fs-label); }
.history-amount { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }

.help { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.help strong { display: block; font-size: var(--fs-sm); font-weight: 600; }
.help span { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }

.settings { max-width: 640px; }

/* ---------- Карточка сотрудника ---------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 120;
  width: min(400px, 100%);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-5);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  overflow-y: auto;
  animation: slide-in 0.2s ease-out;
}
.drawer[hidden] { display: none; }
@keyframes slide-in { from { transform: translateX(16px); opacity: 0; } }

.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.drawer-person { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.drawer-person strong { display: block; font-size: var(--fs-md); font-weight: 600; }

.drawer-facts { display: grid; gap: 0; }
.drawer-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.drawer-facts dt { color: var(--text-muted); font-size: var(--fs-xs); }
.drawer-facts dd { font-size: var(--fs-xs); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

.drawer-actions { display: grid; gap: var(--sp-2); margin-top: auto; }

/* ---------- Диалоги, тост, вход ---------- */

dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(12, 16, 15, 0.5); }

.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.dialog-note { margin: var(--sp-2) 0 var(--sp-5); color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-6); }

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  z-index: 200;
  max-width: min(420px, calc(100vw - 32px));
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-xs);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--risk); color: #fff; }

.login {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
}
.login[hidden] { display: none; }
.login-card {
  width: min(440px, 100%);
  padding: var(--sp-8);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.login-card .brand-mark { width: 32px; height: 32px; margin-bottom: var(--sp-6); }
.login-card h1 { margin-bottom: var(--sp-3); }
.login-card > p { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; }
.login-actions { display: grid; gap: var(--sp-2); margin: var(--sp-6) 0 var(--sp-4); }
.login-card #ssoLogin { margin: var(--sp-6) 0 var(--sp-4); text-decoration: none; }
.login-card #ssoLogin[hidden] { display: none; }
.login-card #loginNotice { margin-top: var(--sp-4); }
.login-card #loginPasswordField { margin-top: var(--sp-6); }
.login-card #loginPasswordField[hidden] { display: none; }
.login-card #loginPasswordField + .form-error { margin-bottom: 0; }

/* ---------- Роли и скелетоны ---------- */

body.is-employee .admin-only { display: none !important; }
body.is-admin [data-view="employee"] { display: none; }

.sk {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-hover) 50%, var(--surface-sunken) 100%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
}
@keyframes sk { to { background-position: -200% 0; } }
.sk-line { height: 10px; }
.sk-task { display: grid; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-right: 1px solid var(--border); }
.sk-task:last-child { border-right: 0; }
.sk-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 90px 90px; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }
.sk-row:first-child { border-top: 0; }
td.sk-cell { padding: 0; }
.sk-dot { height: 28px; border-radius: var(--r-pill); }
.sk-history { display: grid; gap: var(--sp-3); padding-top: var(--sp-4); }

/* ---------- Адаптация ---------- */

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-list { grid-template-columns: 1fr; }
  .task { border-right: 0; border-bottom: 1px solid var(--border); }
  .task:last-child { border-bottom: 0; }
  .employee-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(264px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-3);
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-button { display: grid; }
  main { padding-top: var(--sp-6); }
  .head { flex-direction: column; align-items: stretch; }
  .head .button { align-self: flex-start; }
  .access { grid-template-columns: 1fr; }
  .access-side { border-left: 0; border-top: 1px solid var(--border); }
  .help { flex-direction: column; align-items: stretch; }

  /* Реестр на узком экране: строки становятся карточками,
     чтобы не прятать колонки в горизонтальный скролл. */
  .registry thead { display: none; }
  .registry tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--sp-2) var(--sp-4);
    padding: var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--border);
  }
  .registry tbody tr:first-child { border-top: 0; }
  .registry tbody td { padding: 0; border: 0; }
  .registry tbody td:first-child { grid-column: 1 / -1; }
  .registry tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--text-faint);
    font-size: var(--fs-label);
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  td.col-action { grid-column: 1 / -1; text-align: left; }
  .sk-row { grid-template-columns: 28px minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { display: grid; gap: var(--sp-2); }
  .field.search { width: auto; }
  .panel-head.registry-head { flex-direction: column; align-items: stretch; }
  .topbar .sync { display: none; }
  .drawer { width: 100%; }
  .head .button { width: 100%; }
}

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

@media print {
  .sidebar, .topbar, .drawer, .toast, .scrim { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .panel { box-shadow: none; }
}
