/* ==========================================================================
   RS UI — дизайн-система RS Development (Midnight Volt)
   Единый источник стиля для сайта, RS Console, веб-почты и Telegram Mini App.
   ========================================================================== */

:root {
  /* Цвета */
  --bg: #0B0D10;
  --surface: #111419;
  --surface-2: #161A21;
  --surface-3: #1B2028;
  --line: #1F242C;
  --line-2: #2A303A;
  --text: #F2F4F7;
  --text-2: #C9CED6;
  --muted: #9AA3AE;
  --dim: #6B7480;
  --volt: #C8F135;
  --volt-hover: #D8FF5C;
  --volt-soft: rgba(200, 241, 53, 0.12);
  --ok: #3DDC97;
  --ok-soft: rgba(61, 220, 151, 0.12);
  --warn: #F5C451;
  --warn-soft: rgba(245, 196, 81, 0.12);
  --err: #FF7A73;
  --err-soft: rgba(255, 122, 115, 0.12);
  --info: #7DB8FF;
  --info-soft: rgba(125, 184, 255, 0.12);

  /* Типографика */
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Форма */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(200, 241, 53, 0.18);

  color-scheme: dark;
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--volt); text-decoration: none; }
a:hover { color: var(--volt-hover); }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--volt); color: var(--bg); }
:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
[x-cloak] { display: none !important; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--volt); }
.label-muted { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Логотип RS_ ---------- */
.mark { display: inline-flex; align-items: baseline; font-family: var(--font-head); font-weight: 700; letter-spacing: -0.06em; color: var(--text); line-height: 1; }
.mark::after { content: ""; display: inline-block; width: 0.38em; height: 0.12em; margin-left: 0.08em; background: var(--volt); }
.mark.blink::after { animation: rs-blink 1.1s steps(1) infinite; }
@keyframes rs-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mark.blink::after { animation: none; } }
.logo { display: inline-flex; align-items: baseline; gap: 10px; color: var(--text); font-family: var(--font-head); font-weight: 500; font-size: 18px; }
.logo:hover { color: var(--text); }
.logo small { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; font-weight: 500; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid transparent; background: none; color: var(--text); font: 600 14px/1 var(--font-body); cursor: pointer; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--volt); color: var(--bg); }
.btn-primary:hover { background: var(--volt-hover); color: var(--bg); }
.btn-ghost { border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-subtle { background: var(--surface-2); border-color: var(--line); }
.btn-subtle:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { border-color: rgba(255, 122, 115, .35); color: var(--err); }
.btn-danger:hover { background: var(--err-soft); color: var(--err); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Формы ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--text); font: 400 15px/1.4 var(--font-body); transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 140px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--volt); box-shadow: var(--ring); }
.field-error { font-size: 13px; color: var(--err); }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--volt); }

/* ---------- Карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 17px; font-weight: 600; }
.card-body { padding: 20px 24px; }
.card-foot { padding: 14px 24px; border-top: 1px solid var(--line); }

/* ---------- Метрики ---------- */
.stat { display: flex; flex-direction: column; gap: 8px; padding: 22px 24px; }
.stat-value { font-family: var(--font-head); font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-hint { font-size: 13px; color: var(--muted); }

/* ---------- Бейджи, чипы, статусы ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 500 12px/1.2 var(--font-mono); letter-spacing: .04em; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge-volt { background: var(--volt-soft); color: var(--volt); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip { display: inline-flex; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 500 12px/1.3 var(--font-mono); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex-shrink: 0; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot-err { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }
.dot-volt { background: var(--volt); box-shadow: 0 0 0 4px var(--volt-soft); }

/* ---------- Списки и таблицы ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding: 12px 24px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 24px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .mark { font-size: 32px; opacity: .5; }

/* ---------- Уведомления ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; }
.alert-err { background: var(--err-soft); border-color: transparent; color: #FFC4C0; }
.alert-ok { background: var(--ok-soft); border-color: transparent; color: #B6F2D6; }

/* ---------- Лейаут приложения ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 22px 16px; background: var(--bg); border-right: 1px solid var(--line); }
.sidebar .logo { padding: 4px 10px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { padding: 0 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--volt); }
.nav-item .badge { margin-left: auto; padding: 2px 8px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 12px 0; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font: 700 13px/1 var(--font-head); color: var(--volt); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 32px; background: rgba(11, 13, 16, .85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); min-height: 64px; }
.content { padding: 32px; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 6px; }
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.menu-toggle { display: none; }

/* ---------- Экран входа ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(600px 300px at 50% 0%, rgba(200, 241, 53, 0.06), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 40px 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 22px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-brand .mark { font-size: 54px; }
.auth-foot { text-align: center; font: 500 11px/1 var(--font-mono); letter-spacing: .22em; color: var(--dim); }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
  .card-head, .card-body, .list-item, .table th, .table td { padding-left: 16px; padding-right: 16px; }
  .auth-card { padding: 32px 22px; }
}
