/* ============================================================
   VPN — дизайн-система (админ-панель + клиентский кабинет)
   Тёмная тема — базовая (:root), светлая — body.light
   Все цвета/радиусы/отступы — через CSS custom properties.
   ============================================================ */

/* ---------- Шрифты (локальные, variable) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jbmono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jbmono-cyrillic.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- Токены ---------- */
:root {
  /* палитра — тёмная тема */
  --bg: #060608;
  --surface: #0F0F13;
  --surface-2: #16161C;
  --surface-3: #1C1C24;          /* hover поверх surface-2 */
  --border: #1E1E26;
  --border-2: #2A2A34;           /* граница при hover/focus */
  --text: #FFFFFF;
  --text-2: #A1A1AC;
  --text-3: #6B6B77;
  --accent: #7C6CFF;
  --accent-2: #9A8DFF;           /* hover акцента */
  --accent-glow: rgba(124, 108, 255, .35);
  --accent-soft: rgba(124, 108, 255, .12);
  --green: #2FD873;
  --green-soft: rgba(47, 216, 115, .12);
  --red: #FF4D5E;
  --red-soft: rgba(255, 77, 94, .12);
  --orange: #FFAF3B;
  --orange-soft: rgba(255, 175, 59, .12);
  --gray: #6B6B77;
  --gray-soft: rgba(107, 107, 119, .16);

  --glow-1: rgba(124, 108, 255, .06);
  --glow-2: rgba(80, 120, 255, .04);

  /* типографика */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;

  /* форма */
  --r-card: 16px;
  --r-card-sm: 14px;
  --r-btn: 10px;
  --r-pill: 999px;

  /* глубина */
  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 8px 32px -12px rgba(0,0,0,.5);
  --shadow-lift: 0 2px 4px rgba(0,0,0,.4), 0 16px 48px -16px rgba(0,0,0,.6);
  --shadow-modal: 0 24px 80px -16px rgba(0,0,0,.7);
  --glow-accent: 0 0 0 1px rgba(124,108,255,.4), 0 0 24px -4px var(--accent-glow);

  /* сетка */
  --side-w: 248px;
  --page-max: 1200px;
  --gap: 20px;

  color-scheme: dark;
}

/* светлая тема */
body.light {
  --bg: #FAFAFB;
  --surface: #FFFFFF;
  --surface-2: #F4F4F6;
  --surface-3: #ECECF0;
  --border: #EAEAEF;
  --border-2: #DCDCE4;
  --text: #0A0A0C;
  --text-2: #52525B;
  --text-3: #8E8E99;
  --accent: #6A59F2;
  --accent-2: #5747D6;
  --accent-glow: rgba(106, 89, 242, .22);
  --accent-soft: rgba(106, 89, 242, .09);
  --green: #16A34A;
  --green-soft: rgba(22, 163, 74, .1);
  --red: #E11D48;
  --red-soft: rgba(225, 29, 72, .08);
  --orange: #D97706;
  --orange-soft: rgba(217, 119, 6, .1);
  --gray-soft: rgba(107, 107, 119, .1);
  --glow-1: rgba(106, 89, 242, .05);
  --glow-2: rgba(80, 120, 255, .03);
  --shadow-card: 0 1px 2px rgba(10,10,20,.05), 0 8px 24px -12px rgba(10,10,20,.08);
  --shadow-lift: 0 2px 4px rgba(10,10,20,.05), 0 16px 40px -16px rgba(10,10,20,.14);
  --shadow-modal: 0 24px 80px -16px rgba(10,10,20,.25);
  --glow-accent: 0 0 0 1px rgba(106,89,242,.35), 0 0 20px -6px var(--accent-glow);
  color-scheme: light;
}

/* плавный кросс-фейд при смене темы */
html.theme-anim body,
html.theme-anim body * {
  transition: background-color .45s ease, border-color .45s ease,
              color .45s ease, fill .45s ease, stroke .45s ease,
              box-shadow .45s ease !important;
}

/* ---------- Сброс и база ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* мягкие радиальные подсветки фона */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 70% -10%, var(--glow-1), transparent 70%),
    radial-gradient(800px 500px at 10% 110%, var(--glow-2), transparent 70%);
}

img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

h1, h2, h3, h4 { color: var(--text); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

::selection { background: var(--accent-soft); color: var(--text); }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--mono); font-size: .93em; letter-spacing: -.01em; }
.num  { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* иконки */
.ic { width: 18px; height: 18px; flex: none; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* ============================================================
   МАКЕТ: сайдбар + контент
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  backdrop-filter: blur(12px);
}

.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px;
  color: var(--text);
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
}
.side-brand .logo { width: 30px; height: 30px; }
.side-brand small { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); letter-spacing: .02em; }

.side-section { margin-top: 18px; }
.side-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 10px 6px;
}

.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: var(--r-btn);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active {
  background: var(--accent-soft); color: var(--text);
}
.side-link.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px; background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.side-link.active .ic { color: var(--accent); }
.side-link .ic { color: var(--text-3); transition: color .15s ease; }
.side-link:hover .ic { color: var(--text-2); }

.side-count {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  background: var(--orange-soft); color: var(--orange);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.side-link.danger:hover { background: var(--red-soft); color: var(--red); }
.side-link.danger:hover .ic { color: var(--red); }

/* контент */
.main { flex: 1; min-width: 0; }
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px 32px 64px;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head .sub { margin-top: 4px; color: var(--text-3); font-size: 13.5px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* верхняя панель (кабинет / мобильная) */
.topbar {
  display: flex; align-items: center; gap: 12px;
  max-width: var(--page-max); margin: 0 auto;
  padding: 14px 32px 0;
}
.topbar .spacer { flex: 1; }

/* нижняя таб-панель (мобильные) */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 56px; padding: 6px 8px;
  border-radius: 10px;
  color: var(--text-3); font-size: 10.5px; font-weight: 500;
}
.tab-item .ic { width: 21px; height: 21px; }
.tab-item.active { color: var(--accent); }

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  font-weight: 600; font-size: 13.5px;
  cursor: pointer; user-select: none;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease,
              box-shadow .25s ease, transform .18s ease;
  background: var(--surface-2); color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: .05s; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .ic { width: 16px; height: 16px; margin: 0 -2px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); box-shadow: 0 4px 24px -6px var(--accent-glow); }

.btn-success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.btn-success:hover { background: color-mix(in srgb, var(--green) 20%, transparent); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); }

.btn-warning { background: var(--orange-soft); color: var(--orange); border-color: color-mix(in srgb, var(--orange) 25%, transparent); }
.btn-warning:hover { background: color-mix(in srgb, var(--orange) 20%, transparent); }

.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; gap: 5px; }
.btn-xs .ic { width: 13px; height: 13px; }

.btn-pill { border-radius: var(--r-pill); }
.btn-block { width: 100%; }

/* иконка-кнопка */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-3);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn .ic { width: 16px; height: 16px; }

/* группа ± дней */
.chip-group { display: inline-flex; gap: 4px; }
.chip {
  height: 26px; padding: 0 9px;
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ============================================================
   БЕЙДЖИ-СТАТУСЫ
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge-online  { background: var(--green-soft);  color: var(--green); }
.badge-online .dot { animation: pulse 2s ease-out infinite; }
.badge-active  { background: var(--green-soft);  color: var(--green); }
.badge-offline { background: var(--gray-soft);   color: var(--text-3); }
.badge-frozen  { background: var(--orange-soft); color: var(--orange); }
.badge-warning { background: var(--orange-soft); color: var(--orange); }
.badge-blocked { background: var(--red-soft);    color: var(--red); }
.badge-danger  { background: var(--red-soft);    color: var(--red); }
.badge-disabled{ background: transparent; color: var(--text-3); border: 1px dashed var(--border-2); }
.badge-info    { background: var(--accent-soft); color: var(--accent); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* точка-статус отдельно (в таблицах) */
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status-dot.on  { background: var(--green); animation: pulse 2s ease-out infinite; }
.status-dot.off { background: var(--text-3); }

/* ============================================================
   КАРТОЧКИ
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
.card-hover { transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--shadow-lift);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 20px; }

/* метрика-плитка */
.metric { padding: 18px 20px; position: relative; overflow: hidden; }
.metric-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; color: var(--text-3);
}
.metric-label .ic { width: 15px; height: 15px; }
.metric-value {
  margin-top: 8px;
  font-size: 30px; font-weight: 800; letter-spacing: -.03em;
  color: var(--text); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric-value small { font-size: 15px; font-weight: 600; color: var(--text-3); letter-spacing: 0; }
.metric-sub { margin-top: 8px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.metric-sub.up { color: var(--green); }
.metric-sub.down { color: var(--text-3); }
.metric-sub .ic { width: 13px; height: 13px; }

/* сетки */
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
/* асимметричная сетка: пропорции задаются через --split на элементе */
.grid-split { display: grid; gap: var(--gap); grid-template-columns: var(--split, 1.5fr 1fr); }

/* ============================================================
   ТАБЛИЦЫ
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--r-card) var(--r-card); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: 2px; justify-content: flex-end; }

/* компактный режим (300+ строк) */
.table-compact td { padding: 7px 16px; }
.table-compact .avatar { width: 26px; height: 26px; font-size: 10px; }

/* ячейка-персона */
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user b { color: var(--text); font-weight: 600; display: block; line-height: 1.3; }
.cell-user .small { line-height: 1.3; }

.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.avatar.g { background: var(--green-soft); color: var(--green); }
.avatar.o { background: var(--orange-soft); color: var(--orange); }
.avatar.r { background: var(--red-soft); color: var(--red); }
.avatar.n { background: var(--gray-soft); color: var(--text-2); }

/* rx/tx */
.traffic { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 12px; }
.traffic span { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.traffic .ic { width: 12px; height: 12px; }
.traffic .rx .ic { color: var(--green); }
.traffic .tx .ic { color: var(--accent); }

/* дней до конца — индикация */
.days { font-weight: 600; font-variant-numeric: tabular-nums; }
.days.ok { color: var(--green); }
.days.warn { color: var(--orange); }
.days.crit { color: var(--red); }
.days.inf { color: var(--text-3); }

/* ============================================================
   ФОРМЫ
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 18px; }
.label { font-size: 13px; font-weight: 600; color: var(--text); }
.label small { font-weight: 400; color: var(--text-3); margin-left: 6px; }

.input {
  height: 42px; width: 100%;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--border-2); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 11px 14px; resize: vertical; }
.input.mono { font-family: var(--mono); font-size: 13px; }

.hint { font-size: 12px; color: var(--text-3); }
.field-error .input { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.error-text { font-size: 12px; color: var(--red); display: flex; align-items: center; gap: 5px; }
.error-text .ic { width: 13px; height: 13px; }
.ok-text { font-size: 12px; color: var(--green); display: flex; align-items: center; gap: 5px; }
.ok-text .ic { width: 13px; height: 13px; }

/* инпут с иконкой */
.input-wrap { position: relative; }
.input-wrap .ic {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.input-wrap .input { padding-left: 40px; }
.input-wrap .trail {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
}

/* число со степпером */
.stepper { display: flex; align-items: stretch; }
.stepper .input { border-radius: var(--r-btn) 0 0 var(--r-btn); border-right: none; text-align: center; font-family: var(--mono); }
.stepper button {
  width: 40px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; transition: all .15s ease;
}
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper button:first-of-type { border-right: none; }
.stepper button:last-of-type { border-radius: 0 var(--r-btn) var(--r-btn) 0; }

/* сегментированный контрол / фильтры */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
}
.seg button {
  height: 30px; padding: 0 13px;
  border: none; border-radius: 7px;
  background: transparent; color: var(--text-3);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.seg .n { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg button.active .n { color: var(--accent); }

/* переключатель (switch) */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--border-2);
  transition: background .2s ease, border-color .2s ease;
  pointer-events: none;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-2);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1), background .2s ease;
}
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* переключатель темы */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2);
  cursor: pointer;
  transition: all .2s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-2); transform: rotate(12deg); }
.theme-toggle .ic { width: 16px; height: 16px; }
.theme-toggle .i-sun { display: none; }
body.light .theme-toggle .i-sun { display: block; }
body.light .theme-toggle .i-moon { display: none; }

/* ============================================================
   АЛЕРТЫ
   ============================================================ */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--r-card-sm);
  border: 1px solid;
  font-size: 13px;
}
.alert .ic { width: 17px; height: 17px; margin-top: 1px; flex: none; }
.alert b { display: block; margin-bottom: 1px; font-weight: 600; }
.alert-info    { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text-2); }
.alert-info .ic, .alert-info b { color: var(--accent); }
.alert-warning { background: var(--orange-soft); border-color: color-mix(in srgb, var(--orange) 25%, transparent); color: var(--text-2); }
.alert-warning .ic, .alert-warning b { color: var(--orange); }
.alert-danger  { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 25%, transparent); color: var(--text-2); }
.alert-danger .ic, .alert-danger b { color: var(--red); }
.alert .alert-act { margin-left: auto; align-self: center; }

/* ============================================================
   МОДАЛКА
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 4, 8, .7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-modal);
  transform: translateY(14px) scale(.97);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.1);
}
.modal-backdrop.open .modal { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; padding: 0 20px 20px; }
.modal-foot .btn { flex: 1; }

/* QR-плейсхолдер */
.qr-box {
  width: 216px; height: 216px; margin: 0 auto;
  padding: 12px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border), 0 0 40px -8px var(--accent-glow);
}
.qr-box svg { width: 100%; height: 100%; }

/* ============================================================
   СОСТОЯНИЯ: пустое, skeleton, ошибка
   ============================================================ */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty .empty-ic {
  width: 52px; height: 52px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-3);
}
.empty .empty-ic .ic { width: 24px; height: 24px; }
.empty h4 { color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 320px; }
.empty .btn { margin-top: 16px; }

.empty.error .empty-ic { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 25%, transparent); color: var(--red); }

/* skeleton */
.sk {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border-radius: 6px;
}
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 5%, transparent), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-line { height: 12px; }
.sk-circle { border-radius: 50%; }

/* ============================================================
   ПРОГРЕСС
   ============================================================ */
.progress {
  height: 6px; border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress i {
  display: block; height: 100%; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width 1s cubic-bezier(.3, .7, .3, 1);
}
.progress.green i { background: var(--green); box-shadow: 0 0 12px color-mix(in srgb, var(--green) 40%, transparent); }
.progress.orange i { background: var(--orange); box-shadow: 0 0 12px color-mix(in srgb, var(--orange) 40%, transparent); }
.progress.red i { background: var(--red); box-shadow: 0 0 12px color-mix(in srgb, var(--red) 40%, transparent); }

/* ============================================================
   ПРОЧЕЕ
   ============================================================ */
/* моно-вывод (состояние интерфейса) */
.console {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card-sm);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12px; line-height: 1.8;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre-line;
}
.console .k { color: var(--text-3); }
.console .v { color: var(--text); }
.console .g { color: var(--green); }
.console .a { color: var(--accent); }

/* код-значение с копированием */
.copy-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
}
.copy-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.copy-row .icon-btn { width: 26px; height: 26px; margin: -4px -4px -4px 0; }

/* тултип-«скопировано» */
[data-copied]::after {
  content: "Скопировано"; position: absolute;
  transform: translateY(-34px);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-2);
  font: 600 11px var(--font);
  padding: 4px 8px; border-radius: 6px;
  animation: rise-in .2s ease;
}

/* всплывающие карточки активности */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  min-width: 260px;
  padding: 11px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-2);
  border-radius: var(--r-card-sm);
  box-shadow: var(--shadow-lift);
  font-size: 12.5px; color: var(--text-2);
  animation: toast-in .45s cubic-bezier(.2, .9, .3, 1.1);
}
.toast b { color: var(--text); font-weight: 600; }
.toast .t-ic {
  width: 30px; height: 30px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
}
.toast .t-ic .ic { width: 15px; height: 15px; }
.toast .t-ic.g { background: var(--green-soft); color: var(--green); }
.toast .t-ic.a { background: var(--accent-soft); color: var(--accent); }
.toast .t-ic.o { background: var(--orange-soft); color: var(--orange); }
.toast small { display: block; color: var(--text-3); font-size: 11px; }
.toast.out { animation: toast-out .4s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* пагинация */
.pager { display: flex; align-items: center; gap: 4px; justify-content: center; }
.pager button {
  min-width: 32px; height: 32px; padding: 0 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-2);
  font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: all .15s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.pager button:hover { background: var(--surface-2); color: var(--text); }
.pager button.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.pager button:disabled { opacity: .35; pointer-events: none; }

/* диаграммы */
.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { position: relative; width: 168px; height: 168px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 14; stroke-linecap: round; }
.donut .track { stroke: var(--surface-2); }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-center b { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.02em; font-family: var(--mono); }
.donut-center span { font-size: 11px; color: var(--text-3); }

.legend { display: flex; flex-direction: column; gap: 9px; min-width: 180px; flex: 1; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.legend-row i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row b { color: var(--text); font-weight: 600; }
.legend-row .v { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

.spark { width: 100%; height: 48px; overflow: visible; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.spark .fill { fill: url(#sparkFill); stroke: none; opacity: .6; }
.spark.green .line { stroke: var(--green); }

/* FAQ */
.faq { border-bottom: 1px solid var(--border); }
.faq:last-child { border-bottom: none; }
.faq summary {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 4px; cursor: pointer; list-style: none;
  font-weight: 600; font-size: 13.5px; color: var(--text);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary .ic { margin-left: auto; color: var(--text-3); transition: transform .25s ease; }
.faq[open] summary .ic { transform: rotate(180deg); }
.faq .faq-body { padding: 0 4px 16px; font-size: 13px; color: var(--text-2); max-width: 60ch; }

/* тарифы */
.plan {
  position: relative;
  padding: 18px;
  border: 1px solid var(--border); border-radius: var(--r-card-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all .2s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.plan:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.plan.active { border-color: var(--accent); box-shadow: var(--glow-accent); }
.plan .plan-badge {
  position: absolute; top: -9px; right: 12px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.plan b { font-size: 15px; color: var(--text); }
.plan .price { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.plan .save { font-size: 11.5px; color: var(--green); font-weight: 600; }

/* глобус */
.globe-wrap { position: relative; display: flex; align-items: center; justify-content: center; padding: 8px 0; }
.globe-wrap::before {
  content: ""; position: absolute; width: 62%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 68%);
  opacity: .5; filter: blur(24px);
  pointer-events: none;
}
.globe-wrap canvas { position: relative; max-width: 100%; }

/* ============================================================
   АНИМАЦИИ ПОЯВЛЕНИЯ (JS добавляет .in со стаггером)
   ============================================================ */
html.js [data-reveal] { opacity: 0; transform: translateY(12px); }
html.js [data-reveal].in {
  opacity: 1; transform: none;
  transition: opacity .6s cubic-bezier(.2, .7, .3, 1), transform .6s cubic-bezier(.2, .7, .3, 1);
}
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   ЦЕНТРИРОВАННЫЕ ЭКРАНЫ (логин)
   ============================================================ */
.auth {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; text-align: center; }
.auth-logo .logo { width: 52px; height: 52px; filter: drop-shadow(0 0 18px var(--accent-glow)); }
.auth-logo h1 { font-size: 22px; }
.auth-logo p { color: var(--text-3); font-size: 13px; }
.auth-foot { margin-top: 24px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 1024px) {
  :root { --side-w: 216px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 24px 24px 64px; }
  .topbar { padding: 14px 24px 0; }
}

@media (max-width: 640px) {
  .side { display: none; }
  .tabbar { display: flex; }
  .page { padding: 18px 16px 96px; }
  .topbar { padding: 12px 16px 0; }
  .grid-2, .grid-3, .grid-split { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 22px; }
  .metric-value { font-size: 24px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .modal-foot { flex-direction: column; }
  .donut-wrap { justify-content: center; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { min-width: 0; }
}

/* печать/утилиты */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
