/* =====================================================================
   ФЕРМА ИИ — оформление панели.
   4 темы на CSS-переменных: halo (премиум, по умолчанию), neon, graphite, light.
   Компоненты описаны один раз и используются всеми разделами.
   ===================================================================== */

/* ----------------------------- Темы ----------------------------- */

:root,
[data-theme="halo"] {
  --bg: #07070b;
  --bg-2: #0b0b12;
  --bg-glow-1: rgba(167, 139, 250, .16);
  --bg-glow-2: rgba(240, 171, 252, .10);
  --panel: rgba(20, 20, 28, .62);
  --panel-2: rgba(14, 14, 20, .86);
  --panel-hi: rgba(255, 255, 255, .04);
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(167, 139, 250, .30);
  --text: #edeef4;
  --muted: rgba(237, 238, 244, .58);
  --dim: rgba(237, 238, 244, .34);
  --accent: #a78bfa;
  --accent-2: #f0abfc;
  --accent-soft: rgba(167, 139, 250, .14);
  --accent-soft-2: rgba(240, 171, 252, .10);
  --accent-line: rgba(167, 139, 250, .34);
  --white: #ffffff;
  --ok: #5eead4;
  --warn: #fbbf24;
  --err: #fb7185;
  --info: #93c5fd;
  --shadow: 0 24px 60px rgba(0, 0, 0, .55);
  --halo: 0 0 60px rgba(167, 139, 250, .18);
  --radius: 16px;
}

[data-theme="neon"] {
  --bg: #04080f;
  --bg-2: #071427;
  --bg-glow-1: rgba(34, 211, 238, .16);
  --bg-glow-2: rgba(245, 158, 11, .10);
  --panel: rgba(11, 24, 42, .72);
  --panel-2: rgba(9, 20, 36, .88);
  --panel-hi: rgba(56, 189, 248, .05);
  --line: rgba(56, 189, 248, .18);
  --line-strong: rgba(56, 189, 248, .38);
  --text: #e6f1ff;
  --muted: rgba(190, 215, 240, .58);
  --dim: rgba(190, 215, 240, .34);
  --accent: #22d3ee;
  --accent-2: #f59e0b;
  --accent-soft: rgba(34, 211, 238, .14);
  --accent-soft-2: rgba(245, 158, 11, .10);
  --accent-line: rgba(34, 211, 238, .36);
  --white: #ffffff;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #38bdf8;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --halo: 0 0 40px rgba(34, 211, 238, .20);
  --radius: 14px;
}

[data-theme="graphite"] {
  --bg: #0d0f12;
  --bg-2: #12151a;
  --bg-glow-1: rgba(110, 168, 254, .08);
  --bg-glow-2: rgba(255, 255, 255, .03);
  --panel: #14171c;
  --panel-2: #171b21;
  --panel-hi: rgba(255, 255, 255, .03);
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(110, 168, 254, .35);
  --text: #e8eaee;
  --muted: rgba(232, 234, 238, .60);
  --dim: rgba(232, 234, 238, .35);
  --accent: #6ea8fe;
  --accent-2: #c8b6ff;
  --accent-soft: rgba(110, 168, 254, .14);
  --white: #ffffff;
  --ok: #7ee0b8;
  --warn: #f3c969;
  --err: #ff8a8a;
  --info: #8ab4f8;
  --shadow: 0 12px 28px rgba(0, 0, 0, .35);
  --halo: none;
  --radius: 12px;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --bg-glow-1: rgba(99, 102, 241, .10);
  --bg-glow-2: rgba(236, 72, 153, .06);
  --panel: #ffffff;
  --panel-2: #ffffff;
  --panel-hi: rgba(15, 23, 42, .02);
  --line: rgba(15, 23, 42, .10);
  --line-strong: rgba(99, 102, 241, .35);
  --text: #141824;
  --muted: rgba(20, 24, 36, .62);
  --dim: rgba(20, 24, 36, .40);
  --accent: #5b5bd6;
  --accent-2: #c026d3;
  --accent-soft: rgba(91, 91, 214, .10);
  --white: #0f172a;
  --ok: #0f9d70;
  --warn: #b45309;
  --err: #dc2626;
  --info: #2563eb;
  --shadow: 0 10px 24px rgba(15, 23, 42, .08);
  --halo: none;
  --radius: 12px;
}

[data-theme="minimal"] {
  --bg: #101215;
  --bg-2: #15181c;
  --bg-glow-1: transparent;
  --bg-glow-2: transparent;
  --panel: #171a1f;
  --panel-2: #1b1f24;
  --panel-hi: rgba(255, 255, 255, .025);
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(120, 160, 255, .30);
  --text: #e7e9ee;
  --muted: rgba(231, 233, 238, .60);
  --dim: rgba(231, 233, 238, .38);
  --accent: #7aa2ff;
  --accent-2: #9ec5ff;
  --accent-soft: rgba(122, 162, 255, .12);
  --white: #ffffff;
  --ok: #6fd3a8;
  --warn: #e8c268;
  --err: #ef8b8b;
  --info: #8fb8ff;
  --shadow: none;
  --halo: none;
  --radius: 10px;
}

/* ── Режим «Минимализм»: убираем декор, сжимаем отступы ── */
html.is-minimal .bg-halo,
html.is-minimal body::before { display: none !important; }

html.is-minimal .card,
html.is-minimal .stat,
html.is-minimal .modal,
html.is-minimal .toast,
html.is-minimal .sidebar {
  box-shadow: none !important;
  backdrop-filter: none !important;
}

html.is-minimal .nav__item.is-active { background: var(--panel-hi); box-shadow: none; }

html.is-minimal .card__sub,
html.is-minimal .stat__hint,
html.is-minimal .empty__text,
html.is-minimal .progress__label,
html.is-minimal .barlist__hint { display: none; }

html.is-minimal .view { padding: 14px 18px 28px; }
html.is-minimal .topbar { padding: 12px 18px 8px; }
html.is-minimal .topbar__sub { display: none; }
html.is-minimal .card__body { padding: 12px; }
html.is-minimal .card__head { padding: 10px 12px; }
html.is-minimal .stat { padding: 12px; }
html.is-minimal .stat__value { font-size: 22px; }
html.is-minimal .huge { font-size: 26px; }
html.is-minimal .empty { padding: 20px 14px; }
html.is-minimal .empty__ring { animation: none; border-width: 1px; }
html.is-minimal .grid,
html.is-minimal .grid--kpi,
html.is-minimal .stack { gap: 10px; }
html.is-minimal .table th,
html.is-minimal .table td { padding: 7px 10px; }
html.is-minimal .badge { border-color: transparent; background: transparent; padding: 0 2px; }
html.is-minimal .cr-working::after { display: none; }

/* ----------------------------- База ----------------------------- */

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70%;
  background:
    radial-gradient(60% 60% at 30% 20%, var(--bg-glow-1), transparent 70%),
    radial-gradient(50% 50% at 75% 10%, var(--bg-glow-2), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="graphite"] body::before,
[data-theme="light"] body::before { opacity: .5; }

/* Декоративное светящееся кольцо — отсылка к премиум-стилю */
.bg-halo {
  position: fixed;
  top: -150px;
  right: 9%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5);
  box-shadow: 0 0 90px rgba(167, 139, 250, .35), inset 0 0 60px rgba(240, 171, 252, .25);
  opacity: .35;
  pointer-events: none;
  z-index: 0;
}

[data-theme="neon"] .bg-halo {
  border-color: rgba(34, 211, 238, .5);
  box-shadow: 0 0 80px rgba(34, 211, 238, .3), inset 0 0 50px rgba(56, 189, 248, .2);
}

[data-theme="graphite"] .bg-halo,
[data-theme="light"] .bg-halo { display: none; }

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

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 244px 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent-soft), transparent 70%);
  border: 1px solid var(--line-strong);
  box-shadow: var(--halo);
  color: var(--accent);
}
.brand__name { font-weight: 650; letter-spacing: .04em; }
.brand__sub { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .16s, color .16s, border-color .16s;
}
.nav__item:hover { background: var(--panel-hi); color: var(--text); }
.nav__item.is-active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: var(--halo);
}
.nav__item.is-active .nav__icon { color: var(--accent); }
.nav__icon { display: grid; place-items: center; width: 18px; }
.nav__label { font-size: 13.5px; }

.sidebar__foot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.minimal-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.minimal-toggle:hover { color: var(--text); }
.minimal-toggle input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* min-height: 0 — обязательное условие: без него колонка растягивается
   по содержимому и внутренняя прокрутка раздела не работает. */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 620; letter-spacing: .01em; }
.topbar__sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; }

.view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 20px 24px 48px;
  scrollbar-gutter: stable;
}
.view__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.view__head--bare { justify-content: flex-end; align-items: center; min-height: 0; margin-bottom: 12px; }
.view__title { font-size: 17px; font-weight: 620; }
.view__sub { color: var(--muted); font-size: 12.5px; }
.view__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------- Сетки ---------------------------- */

.grid { display: grid; gap: 14px; }
.grid--kpi { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.split { display: grid; gap: 14px; grid-template-columns: 1.6fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }

/* -------------------------- Карточки -------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-hi), transparent);
}
.card__title { font-size: 12px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card__sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.card__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card__body { padding: 16px; }
.card--flush .card__body { padding: 0; }

/* --------------------------- Тексты --------------------------- */

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 22px; font-weight: 620; }
.huge { font-size: 34px; font-weight: 660; letter-spacing: -.01em; }
.label { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.strong { font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 11.5px;
}
.is-clickable { cursor: pointer; }

/* ---------------------------- KPI ----------------------------- */

.stat {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 15px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: border-color .16s, transform .16s;
}
.stat.is-clickable:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat__icon { color: var(--accent); opacity: .9; }
.stat__label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.stat__value { font-size: 26px; font-weight: 640; margin: 4px 0 2px; }
.stat__hint { font-size: 12px; color: var(--muted); }
.stat--ok .stat__value { color: var(--ok); }
.stat--warn .stat__value { color: var(--warn); }
.stat--error .stat__value { color: var(--err); }
.stat--accent .stat__value { color: var(--accent); }

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

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-hi);
  color: var(--text);
  font: inherit; font-size: 13px;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .1s;
}
.btn:hover { border-color: var(--line-strong); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent; color: #0b0b12; font-weight: 600; }
[data-theme="light"] .btn--primary { color: #fff; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--danger { border-color: rgba(251, 113, 133, .45); color: var(--err); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--icon { padding: 7px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: default; }

.field,
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 13.5px;
  outline: none;
}
.field:focus,
.input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
select.field,
select.input { cursor: pointer; }
textarea.input { min-height: 90px; resize: vertical; }

/* -------------------------- Чипы/бейджи ------------------------ */

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-active { border-color: var(--line-strong); background: var(--accent-soft); color: var(--text); }
.chip__count { font-size: 11.5px; color: var(--dim); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line);
  white-space: nowrap;
}
.badge--ok { color: var(--ok); border-color: rgba(94, 234, 212, .35); background: rgba(94, 234, 212, .10); }
.badge--warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .10); }
.badge--error { color: var(--err); border-color: rgba(251, 113, 133, .35); background: rgba(251, 113, 133, .10); }
.badge--info { color: var(--info); border-color: rgba(147, 197, 253, .35); background: rgba(147, 197, 253, .10); }
.badge--muted { color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot--ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot--warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot--err { background: var(--err); box-shadow: 0 0 10px var(--err); }
.dot--accent { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot--info { background: var(--info); box-shadow: 0 0 10px var(--info); }
.dot--muted { background: var(--dim); }

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

.tablewrap { overflow: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 14px;
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel-2); z-index: 1;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--panel-hi); }
.table tr.is-clickable { cursor: pointer; }
.table .is-right { text-align: right; }
.table .is-center { text-align: center; }
.table--compact th, .table--compact td { padding: 7px 11px; }

/* --------------------------- Списки -------------------------- */

.list { display: flex; flex-direction: column; }
.list__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.list__item:last-child { border-bottom: none; }
.list__item.is-clickable:hover { background: var(--panel-hi); cursor: pointer; }
.list__icon { color: var(--accent); opacity: .85; display: grid; place-items: center; width: 20px; }
.list__main { flex: 1; min-width: 0; }
.list__title { font-size: 13.5px; }
.list__sub { font-size: 12px; margin-top: 2px; }
.list__meta { font-size: 12px; color: var(--dim); white-space: nowrap; }

.kv { display: flex; flex-direction: column; gap: 8px; }
.kv__row { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv__key { font-size: 12.5px; }
.kv__value { font-size: 13px; text-align: right; }

/* ------------------------ Прогресс/графики -------------------- */

.progress { position: relative; height: 8px; border-radius: 999px; background: var(--panel-hi); border: 1px solid var(--line); overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.progress__label { margin-top: 5px; font-size: 11.5px; color: var(--muted); }

.barlist { display: flex; flex-direction: column; gap: 12px; }
.barlist__head { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.barlist__track { height: 10px; border-radius: 999px; background: var(--panel-hi); border: 1px solid var(--line); margin-top: 5px; overflow: hidden; }
.barlist__fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.barlist__fill.is-ok { background: linear-gradient(90deg, var(--ok), var(--accent)); }
.barlist__fill.is-warn { background: linear-gradient(90deg, var(--warn), var(--accent-2)); }
.barlist__fill.is-error { background: linear-gradient(90deg, var(--err), var(--accent-2)); }
.barlist__hint { font-size: 11.5px; margin-top: 4px; }

.spark { width: 100%; }
.spark svg { width: 100%; height: auto; display: block; }

.donutwrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { position: relative; }
.donut__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut__value { font-size: 22px; font-weight: 640; }
.donut__label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .12em; }
.legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 160px; }
.legend__row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; }
.legend__label { flex: 1; color: var(--muted); }
.legend__value { color: var(--text); }

.gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gauge__value { font-size: 30px; font-weight: 660; margin-top: -26px; }
.gauge__label { font-size: 12.5px; color: var(--muted); }
.gauge__hint { font-size: 11.5px; text-align: center; }

/* ------------------------ Пустые состояния -------------------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 20px; text-align: center; }
.empty__icon { display: grid; place-items: center; }
.empty__ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 2px solid var(--line-strong);
  box-shadow: var(--halo);
  animation: pulse 3.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .55; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.03); } }
.empty__title { font-size: 15px; font-weight: 600; }
.empty__text { font-size: 12.5px; color: var(--muted); max-width: 460px; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 20px; }
.loading__ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--panel-hi), var(--accent-soft), var(--panel-hi));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* --------------------------- Модалки -------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 4, 8, .62);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 24px;
}
.modal {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal__title { font-size: 16px; font-weight: 620; }
.modal__sub { font-size: 12.5px; margin-top: 2px; }
.modal__body { padding: 18px; overflow: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.confirm { font-size: 13.5px; line-height: 1.6; }

/* ---------------------------- Тосты --------------------------- */

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 380px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  cursor: pointer;
  animation: toastIn .22s ease-out;
  transition: opacity .25s, transform .25s;
}
.toast--ok { border-color: rgba(94, 234, 212, .45); }
.toast--warn { border-color: rgba(251, 191, 36, .45); }
.toast--error { border-color: rgba(251, 113, 133, .5); }
.toast.is-out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* --------------------------- Логи ----------------------------- */

.logview {
  margin: 0;
  padding: 14px;
  max-height: 460px;
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* --------------------------- Экран входа ---------------------- */

.login { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--bg); }
.login__box {
  width: min(420px, 92vw);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow), var(--halo);
  backdrop-filter: blur(16px);
}
.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login__title { font-size: 20px; font-weight: 640; }
.login__sub { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.login__error { color: var(--err); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.login__hint { font-size: 12px; color: var(--dim); margin-top: 14px; line-height: 1.6; }

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

@media (max-width: 1180px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 76px 1fr; grid-template-rows: 100%; }
  .brand__text, .nav__label, .sidebar__foot .muted { display: none; }
  .nav__item { justify-content: center; padding: 11px 0; }
  .sidebar { padding: 16px 10px; overflow-y: auto; }
  .topbar { padding: 14px 16px 10px; flex-wrap: wrap; }
  .view { padding: 16px 16px 40px; }
}

@media (max-width: 620px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .brand { flex: none; }
  .nav { flex-direction: row; gap: 6px; overflow: visible; }
  .nav__item { padding: 9px 12px; }
  .sidebar__foot { flex-direction: row; border-top: none; padding-top: 0; flex: none; }
  .grid--kpi { grid-template-columns: 1fr 1fr; }
  .stat__value { font-size: 22px; }
  .huge { font-size: 26px; }
  .topbar__right { width: 100%; justify-content: space-between; }
}

/* =====================================================================
   ПРЕМИУМ-ДЕТАЛИ: аккуратные краски, свечение активного, живые карточки.
   Всё построено на переменных темы, поэтому работает в любой палитре.
   ===================================================================== */

:root {
  --accent-glow: 0 0 22px -6px var(--accent);
  --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 42%);
}

/* Мягкий блик сверху карточек — «дорогая бумага» */
.card { position: relative; overflow: hidden; }
.card::after {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 46%;
  background: var(--card-sheen);
  pointer-events: none;
  opacity: .9;
}

/* Заголовки карточек: тонкая акцентная жилка слева */
.card__head { position: relative; }
.card__head::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .85;
}

/* Активный пункт меню: аккуратный световой маркер и свечение */
.nav__item { transition: background .16s ease, color .16s ease, box-shadow .16s ease; }
.nav__item:hover { background: var(--panel-hi); }
.nav__item.is-active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
  box-shadow: inset 2px 0 0 0 var(--accent);
}

/* Кнопка-акцент: бархатный градиент и лёгкое свечение */
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: var(--accent-glow);
  font-weight: 600;
}
.btn--primary:hover { filter: brightness(1.06); }

/* Статистика: подсветка иконки и деликатный градиент по краю */
.stat { position: relative; overflow: hidden; }
.stat::before {
  content: '';
  position: absolute; inset: auto -30% -60% auto;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}

/* Полоски прогресса и «светящиеся» точки статусов */
.dot.is-ok { box-shadow: 0 0 8px var(--ok); }
.dot.is-error { box-shadow: 0 0 8px var(--err); }
.progress__fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Таблицы: аккуратный ховер строки вместо резких линий */
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: var(--panel-hi); }

/* ======================= Блок «С чего начать» ======================= */

.st-card .card__body { padding: 12px; }
.st-steps { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.st-step {
  display: flex; align-items: flex-start; gap: 11px; width: 100%;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  padding: 12px 13px; border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.st-step:hover { border-color: var(--accent-line); transform: translateY(-1px); box-shadow: var(--halo); }
.st-step__num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.st-step--done .st-step__num { background: rgba(94, 234, 212, .14); color: var(--ok); border-color: rgba(94, 234, 212, .34); }
.st-step__body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-step__body b { font-size: 13px; }
.st-step__hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.st-step__go { flex: 0 0 auto; font-size: 11px; color: var(--accent); opacity: .85; align-self: center; white-space: nowrap; }
.st-step--done .st-step__go { color: var(--muted); }

/* Мини-обучение */
.st-train { display: grid; gap: 9px; }
.st-train__row { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: start; }
.st-train__row b { font-size: 12.5px; color: var(--text); }
.st-train__row span { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.st-train__note {
  font-size: 12.5px; line-height: 1.55; color: var(--text);
  padding: 9px 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}

/* ======================= Ключи и доступы ======================= */

.sy-hint { font-size: 12.5px; line-height: 1.55; }
.sy-secret {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  background: var(--panel-2); display: grid; gap: 7px;
}
.sy-secret__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sy-secret__top b { font-size: 12.5px; }
.sy-secret__hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.sy-secret__row { display: flex; gap: 8px; align-items: center; }
.sy-secret__row .field { flex: 1 1 auto; min-width: 0; }

/* ======================= Карта раздела («как это работает») ======================= */

.howto { display: grid; gap: 10px; }
.howto__steps { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.howto__step {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  background: var(--panel-2);
}
.howto__step b { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin-bottom: 4px; }
.howto__step i {
  font-style: normal; width: 19px; height: 19px; border-radius: 7px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.howto__step span { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

/* ======================= Мобильная версия (телефон) ======================= */

@media (max-width: 760px) {
  /* Нижняя навигация: до неё легко дотянуться большим пальцем */
  .app { grid-template-rows: auto 1fr auto; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line); border-right: none; border-bottom: none;
    background: var(--panel-2); backdrop-filter: blur(14px);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { display: none; }
  .sidebar__foot { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav__item {
    flex: 0 0 auto; flex-direction: column; gap: 3px;
    padding: 7px 10px; min-width: 62px; min-height: 52px;
    font-size: 10.5px; border-radius: 12px;
  }
  .nav__item.is-active { box-shadow: none; background: var(--accent-soft); }
  .nav__label { display: block; font-size: 10px; }
  .main { padding-bottom: 76px; }
  .view { padding: 14px 12px 26px; }

  /* Таблицы превращаем в карточки: на телефоне читается лучше */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--line); border-radius: 12px; margin-bottom: 9px;
    padding: 10px 12px; background: var(--panel-2);
  }
  .table td { border: none; padding: 4px 0; }
  .table td:first-child { font-weight: 600; }

  /* Пальцем: крупные зоны нажатия */
  .btn { min-height: 42px; padding: 10px 14px; }
  .btn--sm { min-height: 34px; }
  .chip { min-height: 34px; }
  .field { min-height: 44px; font-size: 16px; } /* 16px — чтобы Safari не зумил */
  .st-steps, .howto__steps { grid-template-columns: 1fr; }
  .st-step__go { display: none; }
  .st-train__row { grid-template-columns: 1fr; gap: 3px; }
  .sy-secret__row { flex-direction: column; align-items: stretch; }
  .grid--kpi { grid-template-columns: 1fr 1fr; gap: 8px; }
  .view__head { flex-direction: column; align-items: flex-start; }
  .view__title { font-size: 20px; }
  .modal { width: calc(100vw - 20px) !important; max-height: 88vh; }
  .toast { left: 10px; right: 10px; bottom: 84px; }
}

/* Установленное приложение (ярлык с телефона): убираем лишние отступы сверху */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
