/* ═══════════════════════════════════════════════════════════════
   Админ-панель Айстудио.рф — оформление в стиле бренда

   Взято с сайта сети: шрифт Manrope, фирменный малиновый #E5097F,
   чистые скруглённые карточки. Здесь всё это в тёмной версии:
   глубокий фон, малиновый акцент, мягкое свечение в шапке.

   Контраст текста везде ≥ 4.5:1 — проверено по формуле WCAG.
   Малиновый для ЗАЛИВОК чуть темнее (#D9087A: белый текст 5.0:1),
   для ТЕКСТА на тёмном чуть светлее (#FF2E94: 5.5:1).
   ═══════════════════════════════════════════════════════════════ */

/* Manrope: из папки fonts/, если файл положили; иначе — с Google
   Fonts (подключено в index.html); иначе — системный шрифт того же
   характера. Панель не ломается ни в одном из случаев. */
@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope.woff2") format("woff2"),
       url("../fonts/Manrope.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg:        #0A0A0E;
  --surface:   #111117;
  --surface-2: #17171E;
  --surface-3: #1E1E27;
  --border:    #25252F;
  --border-2:  #33333F;
  --text:      #F5F5F7;
  --text-2:    #A1A1AD;
  --text-3:    #6E6E7A;

  --brand:     #E5097F;                 /* логотип, декор */
  --accent:    #D9087A;                 /* заливки: белый текст 5.0:1 */
  --accent-2:  #FF2E94;                 /* текст и иконки на тёмном 5.5:1 */
  --accent-bg: rgba(229, 9, 127, .13);
  --glow:      rgba(229, 9, 127, .32);
  --violet:    #7C3AED;                 /* второй цвет переливов, только декор */

  --ok:        #2FBF71;
  --ok-bg:     rgba(47, 191, 113, .14);
  --err:       #F0506E;
  --err-bg:    rgba(240, 80, 110, .14);
  --warn:      #F5A524;
  --warn-bg:   rgba(245, 165, 36, .15);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 9999px;

  --sidebar: 260px;
  --topbar: 60px;
  --content: 1280px;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  --t: 160ms cubic-bezier(.16, 1, .3, 1);
}

[data-theme="light"] {
  --bg:        #F6F6F8;
  --surface:   #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-3: #F0F0F4;
  --border:    #E6E6EC;
  --border-2:  #D3D3DC;
  --text:      #141419;
  --text-2:    #5B5B68;
  --text-3:    #8A8A97;
  --accent-2:  #C9066F;
  --accent-bg: rgba(229, 9, 127, .09);
  --glow:      rgba(229, 9, 127, .18);
  --shadow: 0 1px 2px rgba(20, 20, 30, .06);
  --shadow-lg: 0 20px 60px rgba(20, 20, 30, .14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.card, td, th, pre, .desc, .toast, .assist, .modal { min-width: 0; }
pre { white-space: pre-wrap; }
html, body { max-width: 100%; overflow-x: hidden; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

::selection { background: var(--accent-bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: content-box; }

/* ═══════════ БРЕНД ═══════════
   Словесный знак как на сайте: «Айстудио» и малиновое «.рф». */
.wordmark {
  font-weight: 800; letter-spacing: -.03em; line-height: 1;
  white-space: nowrap; display: inline-flex; align-items: baseline;
}
.wordmark .rf { color: var(--brand); }
.wordmark.shine {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 40%,
              #fff 50%, var(--text) 60%, var(--text) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: wordshine 9s ease-in-out infinite;
}
.wordmark.shine .rf {
  background: linear-gradient(100deg, var(--brand) 0%, var(--brand) 40%,
              #FF8AC4 50%, var(--brand) 60%, var(--brand) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: wordshine 9s ease-in-out infinite;
}
@keyframes wordshine {
  0%, 60% { background-position: 120% 0; }
  100%    { background-position: -120% 0; }
}

/* ═══════════ ВХОД ═══════════ */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; overflow: hidden;
  background: var(--bg);
}
/* мягкое малиновое свечение — медленно дышит, не мешает читать */
.login::before, .login::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  filter: blur(80px); opacity: .55;
}
.login::before {
  width: 720px; height: 720px; left: -200px; top: -260px;
  background: radial-gradient(circle, var(--glow), transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
}
.login::after {
  width: 560px; height: 560px; right: -180px; bottom: -220px;
  background: radial-gradient(circle, rgba(124,58,237,.28), transparent 60%);
  animation: drift 22s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, 40px) scale(1.08); }
}
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 760px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 44px; box-shadow: var(--shadow-lg);
}
.login .wordmark { font-size: 34px; }
.login h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em;
  margin-top: 28px; }
.login .sub { color: var(--text-2); margin-top: 8px; font-size: 15px;
  line-height: 1.55; }
.role-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px; margin-top: 28px;
}
.role-card {
  text-align: left; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; cursor: pointer; transition: all var(--t);
  display: flex; gap: 12px; align-items: flex-start; color: inherit;
  font: inherit; width: 100%; position: relative; overflow: hidden;
}
.role-card::after {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(135deg, var(--accent-bg), transparent 60%);
  transition: opacity var(--t); pointer-events: none;
}
.role-card:hover { border-color: var(--brand); transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(229,9,127,.12); }
.role-card:hover::after { opacity: 1; }
.role-card:active { transform: scale(.985); }
.role-card .ic {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center; background: var(--accent-bg);
  color: var(--accent-2); font-size: 17px;
}
.role-card b { display: block; font-weight: 700; font-size: 15px;
  letter-spacing: -.01em; }
.role-card span { color: var(--text-2); font-size: 13px; display: block;
  margin-top: 3px; line-height: 1.45; }

/* ═══════════ КАРКАС ═══════════ */
.app { display: none; min-height: 100vh; }
.app.on { display: block; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
  transition: transform var(--t);
}
.brand {
  height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border); flex: none;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  display: grid; place-items: center; color: #fff; font-weight: 800;
  font-size: 12px; letter-spacing: -.03em;
  box-shadow: 0 4px 14px var(--glow);
}
.brand .wordmark { font-size: 19px; }
.brand small { color: var(--text-3); font-size: 11px; display: block;
  line-height: 1; margin-top: 3px; font-weight: 500; letter-spacing: .02em; }

.nav { flex: 1; overflow-y: auto; padding: 14px 10px 24px; }
.nav-group { margin-bottom: 6px; }
.nav-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-3); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 38px;
  padding: 0 12px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-size: 14px; font-weight: 500; position: relative;
  transition: background var(--t), color var(--t); width: 100%;
  background: none; border: 0; font-family: inherit; text-align: left;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.on { background: var(--accent-bg); color: var(--text); font-weight: 600; }
.nav-item.on::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
  box-shadow: 0 0 12px var(--glow);
}
.nav-item .ic { width: 18px; text-align: center; flex: none; font-size: 15px;
  color: var(--text-3); }
.nav-item.on .ic { color: var(--accent-2); }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: var(--surface-3);
  color: var(--text-2); padding: 1px 7px; border-radius: var(--r-full);
}

.main { margin-left: var(--sidebar); min-height: 100vh; }

/* Шапка: мягкий перелив, который медленно идёт слева направо, и тонкая
   светящаяся линия снизу. Всё низкой яркости — текст читается как на
   ровном фоне, а движение ловится краем глаза. */
.topbar {
  height: var(--topbar); position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  overflow: hidden;
}
.topbar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg,
    transparent 0%, rgba(229,9,127,.10) 35%, rgba(124,58,237,.10) 50%,
    rgba(229,9,127,.10) 65%, transparent 100%);
  background-size: 220% 100%;
  animation: sweep 14s linear infinite;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, var(--brand) 35%,
    var(--violet) 55%, var(--brand) 75%, transparent 100%);
  background-size: 200% 100%; opacity: .7;
  animation: sweep 10s linear infinite;
}
@keyframes sweep {
  from { background-position: 120% 0; }
  to   { background-position: -120% 0; }
}
.topbar > * { position: relative; }
.crumb { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.crumb small { color: var(--text-3); font-weight: 500; font-size: 13px;
  margin-left: 8px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }

.wrap { max-width: var(--content); margin: 0 auto; padding: 24px; }

.asbanner {
  height: 44px; display: none; align-items: center; gap: 12px;
  padding: 0 24px; background: var(--warn-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn); font-size: 13px; font-weight: 600;
}
.asbanner.on { display: flex; }

/* ═══════════ МЕЛОЧИ: ОТСТУПЫ И ТЕКСТ ═══════════ */
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.kpi-l { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.45; }

/* ═══════════ ЭЛЕМЕНТЫ ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; height: 36px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all var(--t); white-space: nowrap;
  letter-spacing: -.005em;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 6px 18px var(--glow); }
.btn.primary:hover { background: var(--brand); border-color: var(--brand);
  box-shadow: 0 8px 24px var(--glow); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 12px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }
.field .err { font-size: 12px; color: var(--err); margin-top: 6px;
  line-height: 1.4; visibility: hidden; }
.field.bad .err { visibility: visible; }
.field.bad input, .field.bad textarea, .field.bad select { border-color: var(--err); }

input[type=text], input[type=number], input[type=password],
input[type=search], textarea, select {
  width: 100%; height: 38px; padding: 0 12px; font-size: 14px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 10px;
  font-family: inherit; transition: border-color var(--t), box-shadow var(--t);
}
textarea { height: auto; min-height: 92px; padding: 10px 12px; line-height: 1.55;
  resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23A1A1AD' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px; margin-bottom: 16px;
}
.card > h3, .card-title {
  font-size: 15px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
.card .desc { color: var(--text-2); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }

.grid { display: grid; gap: 16px; }
/* Ячейка сетки по умолчанию не даёт себя сжать уже содержимого — и широкая
   таблица внутри растягивает всю страницу. min-width:0 это выключает. */
.grid > *, .row > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }

/* KPI: число крупно, база сравнения под ним — без неё цифра пустая */
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand), transparent 70%); opacity: .5;
}
.kpi .lbl { font-size: 13px; color: var(--text-2); display: flex; align-items: center;
  gap: 6px; font-weight: 500; }
.kpi .val { font-size: 32px; font-weight: 800; letter-spacing: -.03em;
  margin-top: 8px; line-height: 1.05; }
.kpi .sub { font-size: 13px; color: var(--text-2); margin-top: 6px; font-weight: 500; }
.kpi .sub.up { color: var(--ok); }
.kpi .sub.down { color: var(--err); }

.bar { height: 6px; background: var(--surface-3); border-radius: var(--r-full);
  overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), var(--brand));
  transition: width 400ms cubic-bezier(.16,1,.3,1); }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.err { background: var(--err); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  position: sticky; top: 0; background: var(--surface); z-index: 2;
  text-align: left; font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle;
  /* в таблице слова не рвём посередине — лучше пусть таблица листается */
  overflow-wrap: normal; word-break: normal; }
td b, td .num, td.num { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dense td { padding: 8px 16px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  font-weight: 600; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.accent { background: var(--accent-bg); color: var(--accent-2); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.warn { background: var(--warn); }

.empty { text-align: center; padding: 48px 24px; }
.empty .ic { font-size: 34px; opacity: .45; }
.empty p { color: var(--text-2); font-size: 14px; margin: 12px 0 16px;
  max-width: 420px; margin-inline: auto; line-height: 1.55; }

.sw { position: relative; width: 40px; height: 24px; flex: none; cursor: pointer; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0;
  cursor: pointer; z-index: 2; }
.sw i { position: absolute; inset: 0; background: var(--surface-3);
  border: 1px solid var(--border-2); border-radius: var(--r-full); transition: all var(--t); }
.sw i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-2); transition: all var(--t); }
.sw input:checked + i { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow); }
.sw input:checked + i::after { transform: translateX(16px); background: #fff; }

.toggle-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tx { flex: 1; }
.toggle-row b { font-size: 14px; font-weight: 600; display: block; }
.toggle-row .tx > span { font-size: 13px; color: var(--text-2); display: block;
  margin-top: 2px; line-height: 1.45; }
.toggle-row b .tag { display: inline-flex; margin-left: 6px; vertical-align: middle; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(4, 4, 8, .7); z-index: 90;
  display: none; place-items: center; padding: 24px; backdrop-filter: blur(4px);
}
.modal-bg.on { display: grid; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 88vh; display: flex; flex-direction: column;
  animation: pop 200ms cubic-bezier(.16,1,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal header { padding: 22px 24px 0; }
.modal header h3 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.modal header p { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.modal .body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal footer { padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px; pointer-events: none; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-left: 3px solid var(--brand); border-radius: 12px; padding: 12px 16px;
  font-size: 14px; box-shadow: var(--shadow-lg);
  animation: slide 220ms cubic-bezier(.16,1,.3,1);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast b { display: block; font-weight: 700; font-size: 14px; }
.toast span { color: var(--text-2); font-size: 13px; display: block; margin-top: 2px; line-height: 1.45; }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

.steps { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500;
  color: var(--text-3); padding: 7px 13px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
}
.step.on { color: var(--text); border-color: var(--brand); background: var(--accent-bg); }
.step.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.step .n { width: 18px; height: 18px; border-radius: 50%; flex: none; display: grid;
  place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); }
.step.on .n { background: var(--accent); color: #fff; }
.step.done .n { background: var(--ok); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: var(--r-full); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-2); background: var(--surface-2); cursor: pointer;
  transition: all var(--t); color: var(--text); font-family: inherit;
}
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--accent-bg); border-color: var(--brand); color: var(--accent-2);
  font-weight: 600; }

.assist {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); margin-bottom: 20px;
}
.assist .av { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid;
  place-items: center; background: linear-gradient(135deg, var(--brand), var(--violet));
  color: #fff; font-size: 14px; }
.assist .tx { font-size: 14px; line-height: 1.55; }
.assist .tx b { display: block; margin-bottom: 3px; font-weight: 700; }

code, .mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--surface-3); padding: 2px 7px; border-radius: 6px; color: var(--accent-2); }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
pre code { background: none; padding: 0; color: var(--text); }

.chart { width: 100%; height: 200px; display: block; }

.search { position: relative; }
.search input { padding-left: 36px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 14px; pointer-events: none; }

.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px;
  border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 500;
  padding: 0 13px; min-height: 30px; border-radius: 7px; cursor: pointer; font-family: inherit;
  transition: all var(--t); }
.seg button.on { background: var(--surface-3); color: var(--text); font-weight: 600; }

/* ═══════════ БЫСТРЫЙ ПОИСК (Cmd+K) ═══════════ */
.pal-bg { position: fixed; inset: 0; background: rgba(4,4,8,.6); z-index: 95;
  display: none; align-items: flex-start; justify-content: center; padding: 12vh 24px 24px;
  backdrop-filter: blur(4px); }
.pal-bg.on { display: flex; }
.pal { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop 180ms cubic-bezier(.16,1,.3,1); }
.pal input { height: 54px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  font-size: 16px; padding: 0 18px; background: transparent; }
.pal input:focus { box-shadow: none; border-color: var(--border); }
.pal .list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal .it { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font-size: 14px; }
.pal .it .ic { width: 22px; text-align: center; color: var(--text-3); }
.pal .it small { color: var(--text-3); margin-left: auto; font-size: 12px; }
.pal .it.on, .pal .it:hover { background: var(--accent-bg); }
.pal .it.on .ic { color: var(--accent-2); }
.pal .hint { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px;
  color: var(--text-3); display: flex; gap: 14px; }
kbd { font-family: inherit; font-size: 11px; background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: 5px; padding: 1px 6px; color: var(--text-2); }

/* ═══════════ НИЗ МЕНЮ: КТО ВОШЁЛ ═══════════ */
.side-foot { border-top: 1px solid var(--border); padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex: none; }
.side-foot .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.side-foot .av { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid;
  place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--violet)); }
.side-foot .nm { min-width: 0; flex: 1; }
.side-foot .nm b { display: block; font-size: 13px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.side-foot .nm span { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.side-foot .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.side-foot .acts .btn { flex: 1; }
.side-foot .mob-only { display: none; }

.scrim { position: fixed; inset: 0; background: rgba(4,4,8,.6); z-index: 39; display: none;
  backdrop-filter: blur(2px); }
body.nav-open .scrim { display: block; }

/* ═══════════ НИЖНЯЯ ПАНЕЛЬ (ТЕЛЕФОН) ═══════════ */
.tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 38;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
.tabbar:empty { display: none; }
.tabbar button { flex: 1; min-width: 0; border: 0; background: none; font-family: inherit;
  color: var(--text-3); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; cursor: pointer;
  padding: 6px 2px; letter-spacing: .01em; }
.tabbar button .ic { font-size: 19px; line-height: 1; color: var(--text-2); }
.tabbar button span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.tabbar button.on { color: var(--accent-2); }
.tabbar button.on .ic { color: var(--accent-2); }

.burger { display: none; width: 40px; height: 40px; padding: 0; font-size: 18px; flex: none; }

/* ═══════════ ГРАФИКИ ═══════════
   Рисуются в реальную ширину контейнера (см. fitCharts), поэтому текст и
   точки не сплющиваются на узком экране. */
.chartbox { width: 100%; min-width: 0; }
.chart { width: 100%; height: 200px; display: block; }

/* ═══════════ АДАПТИВ ═══════════
   Три режима. Ширина — единственное, что решает:
   • ≥ 1001px  компьютер: меню слева всегда;
   • 601–1000  планшет: меню выезжает по кнопке, внизу — вкладки;
   • ≤ 600     телефон: то же, плюс всё в одну колонку, окна снизу.  */
:root { --tabbar: 0px; }

@media (max-width: 1240px) {
  :root { --sidebar: 228px; }
  .brand { padding: 0 16px; }
}

@media (max-width: 1100px) {
  /* две таблицы рядом уже не помещаются — одна под другой */
  .g2 { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  :root { --tabbar: 58px; }
  .sidebar { transform: translateX(-100%); width: min(304px, 86vw);
    box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
  .main { margin-left: 0;
    padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); }
  .burger { display: inline-flex; }
  .tabbar { display: flex; }
  .topbar .desk-only { display: none; }
  .side-foot .mob-only { display: flex; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .toasts { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); }
  .crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
}

@media (max-width: 600px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .wrap { padding: 14px; }
  .topbar { padding: 0 10px 0 8px; gap: 8px; }
  .crumb { font-size: 15px; }
  .crumb small { display: none; }
  .asbanner { height: auto; padding: 10px 14px; flex-wrap: wrap; font-size: 12px; }
  .card { padding: 16px; border-radius: 14px; }
  .kpi { padding: 16px; }
  .kpi .val { font-size: 26px; }
  .row { flex-wrap: wrap; }
  .row .right { margin-left: auto; }
  /* поиск на телефоне — во всю ширину, кнопки под ним */
  .row > .search { flex: 1 1 100%; max-width: none !important; }
  .search .ic { font-size: 15px; }
  th { padding: 10px 12px; }
  td { padding: 11px 12px; }
  .dense td { padding: 7px 12px; }
  .login { padding: 12px; }
  .login-card { padding: 26px 18px; border-radius: 16px; }
  .login .wordmark { font-size: 28px; }
  .login h1 { font-size: 24px; margin-top: 20px; }
  .role-grid { grid-template-columns: 1fr; }
  /* iOS увеличивает страницу, если шрифт в поле меньше 16px */
  input, select, textarea { font-size: 16px; }
  .chart { height: 160px; }
  /* Окна — снизу, как лист: до них дотянуться большим пальцем */
  .modal-bg { padding: 0; align-items: end; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh;
    border-bottom: 0; animation: sheet 220ms cubic-bezier(.16,1,.3,1); }
  .modal header { padding: 18px 18px 0; }
  .modal .body { padding: 16px 18px; }
  .modal footer { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .modal footer .btn { flex: 1; }
  .toasts { left: 12px; right: 12px; max-width: none; }
  .steps { gap: 6px; }
  .step { padding: 6px 10px; font-size: 12px; }
  .pal-bg { padding: 8px; align-items: flex-start; }
  /* мастер: «Дальше» — во всю ширину и первым, остальное ниже */
  .wz-foot { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .wz-foot .wz-go { flex-direction: column-reverse; margin-left: 0; gap: 8px; }
  .wz-foot .btn { width: 100%; }
  .pal input { height: 48px; font-size: 16px; }
}
@keyframes sheet { from { opacity: 0; transform: translateY(40px); } }

/* Пальцем попадать труднее, чем мышью: цели не меньше 40px */
@media (pointer: coarse) {
  .btn.sm { min-height: 36px; padding: 0 12px; }
  .btn { min-height: 42px; }
  .nav-item { height: 44px; }
  .chip { padding: 10px 15px; }
  .seg button { min-height: 36px; }
  .sw { width: 46px; height: 27px; }
  .sw i::after { width: 21px; height: 21px; }
  .sw input:checked + i::after { transform: translateX(19px); }
  tbody tr:hover { background: none; }
}

/* Таблица шире экрана — тень справа подсказывает, что можно листать */
.tbl-wrap {
  background:
    linear-gradient(90deg, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(270deg, var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
    linear-gradient(90deg, rgba(0,0,0,.35), transparent) left / 14px 100% no-repeat scroll,
    linear-gradient(270deg, rgba(0,0,0,.35), transparent) right / 14px 100% no-repeat scroll,
    var(--surface);
}
.tbl-wrap table { background: transparent; }
.tbl-wrap th { background: var(--surface); }
