/* =====================================================================
   Delta — дизайн-система
   ===================================================================== */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --side-w: 252px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --grad: linear-gradient(135deg, #7c8cff 0%, #4fb0f5 55%, #22d3ee 100%);
  --accent: #7c8cff; --accent-2: #22d3ee;
  --ok: #22c55e; --bad: #f43f5e; --warn: #f59e0b; --info: #38bdf8;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14; --bg-2: #0e121a; --surface: #121722; --surface-2: #171d2a; --surface-3: #1d2434;
  --line: #222a3a; --line-2: #2c3547;
  --text: #e7eaf2; --text-2: #b8c0d0; --muted: #7f899c;
  --accent-soft: rgba(124, 140, 255, .14); --accent-text: #a5b0ff;
  --ok-soft: rgba(34, 197, 94, .14); --bad-soft: rgba(244, 63, 94, .14); --warn-soft: rgba(245, 158, 11, .15); --info-soft: rgba(56, 189, 248, .14);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45); --shadow-sm: 0 2px 10px rgba(0, 0, 0, .25);
  --sel: rgba(124, 140, 255, .16); --sel-line: rgba(124, 140, 255, .45);
  --backdrop: rgba(5, 7, 12, .66);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb; --bg-2: #eef1f8; --surface: #ffffff; --surface-2: #f8f9fc; --surface-3: #eef1f7;
  --line: #e3e7f0; --line-2: #d5dbe7;
  --text: #121826; --text-2: #3d4659; --muted: #6b7489;
  --accent-soft: rgba(99, 112, 240, .11); --accent-text: #4f5de0;
  --ok-soft: #e7f7ee; --bad-soft: #fdecef; --warn-soft: #fdf3e1; --info-soft: #e6f5fd;
  --shadow: 0 12px 40px rgba(20, 30, 60, .14); --shadow-sm: 0 2px 8px rgba(20, 30, 60, .06);
  --sel: rgba(99, 112, 240, .10); --sel-line: rgba(99, 112, 240, .45);
  --backdrop: rgba(18, 24, 38, .42);
  --ok: #16a34a; --bad: #e11d48; --warn: #d97706;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--sel-line); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.right { text-align: right; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
svg.i.sm { width: 15px; height: 15px; vertical-align: -3px; }

/* ---------- Скроллбары ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- Формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field > small { color: var(--muted); font-size: 12px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, select.input {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea, textarea.input { height: auto; min-height: 96px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-2); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
select.input, .field select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f899c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input[type=date].input, .field input[type=date], .field input[type=time] { padding-right: 8px; }
.grid { display: grid; gap: 0 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; }

/* переключатель */
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin: 4px 0 12px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; transition: background .2s var(--ease); margin-top: 1px; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .22s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch .lbl { line-height: 1.4; }
.switch .lbl small { display: block; color: var(--muted); font-size: 12px; }

/* чекбокс */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); background: var(--surface-2); display: grid; place-items: center; transition: .15s; cursor: pointer; margin: 0; flex: none; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ''; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-2); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 18px -6px rgba(124, 140, 255, .65); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text) transparent var(--text) transparent; animation: spin .7s linear infinite; }
.btn.primary.loading::after { border-color: #fff transparent #fff transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Значки ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.b-ok, .b-sent { background: var(--ok-soft); color: var(--ok); }
.b-bad, .b-rejected, .b-no_flow, .b-error, .b-invalid { background: var(--bad-soft); color: var(--bad); }
.b-warn, .b-duplicate { background: var(--warn-soft); color: var(--warn); }
.b-info, .b-new, .b-hold, .b-running { background: var(--info-soft); color: var(--info); }
.b-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; background: var(--surface-3); font-size: 12.5px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dep { color: var(--ok); font-weight: 700; }

/* ---------- Каркас ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: var(--side-w); flex: none; position: fixed; inset: 0 auto 0 0; z-index: 50;
  background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  transition: transform .3s var(--ease);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 14px; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.brand b { font-size: 19px; font-weight: 800; letter-spacing: -.4px; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: .2px; margin-top: -2px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav h6 { margin: 16px 10px 6px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 500; position: relative; transition: background .15s, color .15s; margin-bottom: 1px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent-text); }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.nav .cnt { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--grad); color: #fff; }
.me { border-top: 1px solid var(--line); padding: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--grad); color: #fff; flex: none; font-size: 13px; }
.me .who { flex: 1; min-width: 0; line-height: 1.25; }
.me .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.me .who small { color: var(--muted); font-size: 11.5px; }
.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .burger { display: none; }
.topbar .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page { padding: 8px 28px 40px; animation: pageIn .35s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.side-backdrop { display: none; }

/* ---------- Карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 24px 0 12px; }
.section-title h2 { margin: 0; font-size: 15.5px; font-weight: 650; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: auto; }
.hint { display: flex; gap: 10px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text-2); border-radius: var(--r-sm); padding: 11px 13px; font-size: 13px; margin-bottom: 14px; line-height: 1.55; }
.hint svg { color: var(--accent-text); margin-top: 1px; }
.hint code, .doc code, td code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--text); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; overflow: hidden; animation: pop .45s var(--ease) both; }
.kpi:nth-child(2) { animation-delay: .04s } .kpi:nth-child(3) { animation-delay: .08s } .kpi:nth-child(4) { animation-delay: .12s } .kpi:nth-child(5) { animation-delay: .16s } .kpi:nth-child(6) { animation-delay: .2s }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi b { display: block; font-size: 24px; font-weight: 750; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.accent::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); }
.kpi .pos { color: var(--ok); } .kpi .neg { color: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Таблицы ---------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; position: relative; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.wrap { white-space: normal; min-width: 180px; }
.tbl .sub { display: block; color: var(--muted); font-size: 12px; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.tbl.select tbody tr { cursor: default; user-select: none; }
.tbl.select tbody tr.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.tbl.select tbody tr.sel:hover { background: var(--sel); }
.tbl .ck { width: 40px; }
.tbl .open-btn { opacity: .55; transition: opacity .15s; }
.tbl tr:hover .open-btn { opacity: 1; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: 8px; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pager .grow { flex: 1; }
.bar { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transform-origin: left; animation: grow .7s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* скелетон */
.sk { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* панель выделения */
.selbar { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); z-index: 45; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); border-radius: 14px; padding: 10px 12px 10px 16px; transition: transform .35s var(--ease), opacity .25s; opacity: 0; max-width: calc(100vw - 24px); }
.selbar.show { transform: translate(-50%, 0); opacity: 1; }
.selbar b { font-variant-numeric: tabular-nums; }

/* ---------- Слои: модальные окна, панели ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; animation: fade .2s ease; }
.overlay.closing { animation: fadeOut .18s ease forwards; }
@keyframes fade { from { opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }
.modal { margin: auto; width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: modalIn .28s var(--ease); }
.modal.wide { width: min(1000px, calc(100vw - 32px)); }
.modal.narrow { width: min(440px, calc(100vw - 32px)); }
.overlay.closing .modal { animation: modalOut .18s ease forwards; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes modalOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
.m-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.m-head h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.m-body { padding: 4px 20px 8px; overflow-y: auto; }
.m-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-ov { justify-content: flex-end; }
.drawer { width: min(640px, 100vw); height: 100%; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn .32s var(--ease); }
.overlay.closing .drawer { animation: slideOut .2s ease forwards; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes slideOut { to { transform: translateX(40px); opacity: 0; } }
.drawer .m-body { flex: 1; padding-bottom: 24px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; background: none; border: 0; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 550; white-space: nowrap; transition: color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad); }
.tab-pane { animation: pageIn .25s var(--ease); }

.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 7px 14px; font-size: 13.5px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div { word-break: break-word; }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tl { position: relative; padding: 0 0 14px; }
.tl::before { content: ''; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.tl.ok::before { border-color: var(--ok); } .tl.bad::before { border-color: var(--bad); } .tl.acc::before { border-color: var(--accent); }
.tl .meta { font-size: 12px; color: var(--muted); }
pre.code { margin: 6px 0 0; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
details > summary { cursor: pointer; color: var(--accent-text); font-size: 12.5px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 32px)); padding: 11px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: toastIn .35s var(--ease); font-weight: 500; }
.toast.out { animation: toastOut .25s ease forwards; }
.toast svg { flex: none; }
.toast.ok svg { color: var(--ok); } .toast.bad svg { color: var(--bad); } .toast.info svg { color: var(--accent-text); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login::before, .login::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(90px); opacity: .35; pointer-events: none; animation: float 14s ease-in-out infinite alternate; }
.login::before { background: #7c8cff; top: -180px; left: -140px; }
.login::after { background: #22d3ee; bottom: -200px; right: -160px; animation-delay: -7s; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.1); } }
.login-box { position: relative; z-index: 1; width: 100%; max-width: 380px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px 26px; box-shadow: var(--shadow); animation: modalIn .5s var(--ease); }
.login-box .brand { justify-content: center; padding: 0 0 22px; }
.login-box .brand img { width: 46px; height: 46px; border-radius: 13px; }
.login-box .brand b { font-size: 26px; }
.login-box .btn { width: 100%; height: 42px; margin-top: 6px; }
.login .err { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 10px; text-align: center; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- Документация ---------- */
.doc { max-width: 920px; }
.doc h2 { font-size: 17px; margin: 30px 0 10px; }
.doc h3 { font-size: 14.5px; margin: 20px 0 8px; }
.doc p { color: var(--text-2); margin: 8px 0; }
.doc pre { background: #0a0d14; color: #d6deeb; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; overflow: auto; font: 12.5px/1.6 var(--mono); position: relative; }
.doc .tbl-wrap { margin: 10px 0; }
.doc .tbl td { white-space: normal; }
.method { display: inline-block; font: 700 11px var(--mono); padding: 2px 7px; border-radius: 5px; margin-right: 6px; }
.method.post { background: var(--ok-soft); color: var(--ok); } .method.get { background: var(--info-soft); color: var(--info); }
.copy-btn { position: absolute; top: 8px; right: 8px; }
.pre-wrap { position: relative; }
.pre-wrap > pre { padding-right: 44px; }
.pre-copy { position: absolute; top: 6px; right: 6px; opacity: .75; gap: 5px; backdrop-filter: blur(4px); }
.pre-copy span { display: none; }
.pre-wrap:hover .pre-copy { opacity: 1; }
.pre-wrap:hover .pre-copy span { display: inline; }
.kv .mono, code:not(pre code) { cursor: copy; }
@media (hover: none) { .pre-copy { opacity: 1; } }

/* потоки */
.flow { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; animation: pop .35s var(--ease) both; }
.flow .prio { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 750; background: var(--surface-3); color: var(--text-2); }
.flow.off { opacity: .6; }
.flow .name { font-weight: 650; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flow .conds { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.split { display: flex; height: 8px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 4px 0 8px; }
.split i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; background: var(--c); }
.rows-edit { width: 100%; border-collapse: collapse; }
.rows-edit td, .rows-edit th { padding: 5px 6px 5px 0; text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.rows-edit .input { height: 34px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.perm-group { margin: 12px 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.verdict { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); font-weight: 600; margin: 10px 0; animation: pop .3s var(--ease); }
.verdict.ok { background: var(--ok-soft); color: var(--ok); } .verdict.bad { background: var(--bad-soft); color: var(--bad); } .verdict.warn { background: var(--warn-soft); color: var(--warn); }
.progress { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; transition: width .5s var(--ease); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* =====================================================================
   Мобильная версия
   ===================================================================== */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .side { transform: translateX(-102%); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 48; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .side-backdrop.show { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { padding: 0 14px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .topbar .burger { display: inline-flex; }
  .topbar .acts .btn:not(.icon) .t { display: none; }
  .topbar .acts .btn:not(.icon) { width: 38px; padding: 0; }
  .page { padding: 6px 14px calc(90px + env(safe-area-inset-bottom)); }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .perm-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv > div:nth-child(even) { margin-bottom: 8px; }
  .toolbar > * { flex: 1 1 140px; }
  .toolbar .input { width: 100%; }
  .toolbar.filters.collapsed > :not(.always) { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; } .kpi b { font-size: 20px; }
  /* таблицы → карточки */
  .tbl-wrap.cards { background: transparent; border: 0; overflow: visible; }
  .cards table.tbl, .cards .tbl tbody, .cards .tbl tr, .cards .tbl td { display: block; width: 100%; }
  .cards .tbl thead { display: none; }
  .cards .tbl tfoot { display: block; }
  .cards .tbl tfoot tr { display: block; }
  .cards .tbl tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; padding: 8px 4px; position: relative; }
  .cards .tbl td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 12px; white-space: normal; text-align: right; }
  .cards .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; max-width: 45%; }
  .cards .tbl td.num { text-align: right; }
  .cards .tbl td[data-label=""]::before, .cards .tbl td:not([data-label])::before { display: none; }
  .cards .tbl td.ck { position: absolute; right: 6px; top: 6px; width: auto; padding: 4px; }
  .cards .tbl.select td.ck + td { padding-right: 48px; }
  .cards .tbl td:empty, .cards .tbl td.mhide { display: none; }
  .cards .tbl td.actions { justify-content: flex-end; }
  .cards .tbl td.wrap { min-width: 0; }
  .cards .tbl tfoot td { background: var(--surface-2); border-radius: var(--r); }
  .modal, .modal.wide, .modal.narrow { width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; animation: sheetIn .32s var(--ease); }
  .overlay.closing .modal { animation: sheetOut .2s ease forwards; }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  @keyframes sheetOut { to { transform: translateY(100%); } }
  .m-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .m-foot .btn { flex: 1; }
  .drawer { width: 100vw; }
  .toasts { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); align-items: stretch; }
  .selbar { bottom: calc(12px + env(safe-area-inset-bottom)); width: calc(100vw - 20px); justify-content: space-between; }
  .flow { grid-template-columns: auto 1fr; }
  .flow .f-acts { grid-column: 1 / -1; }
}
@media (hover: none) {
  .tbl .open-btn { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.token-field { width: 100%; font: 13px/1.5 var(--mono); padding: 10px 12px; cursor: text; }
/* обновление: прогресс */
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.spinner.lg { width: 30px; height: 30px; border-width: 3px; color: var(--accent); flex: none; }
.upd-card.ok { border-color: var(--ok); } .upd-card.bad { border-color: var(--bad); }
.upd-head { display: flex; gap: 14px; align-items: flex-start; }
.upd-ico { width: 30px; height: 30px; display: grid; place-items: center; flex: none; }
.upd-card.ok .upd-ico { color: var(--ok); } .upd-card.bad .upd-ico { color: var(--bad); }
.upd-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.upd-now { font-size: 18px; font-weight: 700; margin: 2px 0 4px; }
.upd-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 14px 0 12px; }
.upd-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #38bdf8); border-radius: inherit; transition: width .6s var(--ease); }
.upd-card.ok .upd-bar i { background: var(--ok); } .upd-card.bad .upd-bar i { background: var(--bad); }
.upd-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.upd-steps li { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.upd-steps .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 11px; }
.upd-steps li.ok { color: var(--ok); } .upd-steps li.ok .dot { border-color: var(--ok); background: var(--ok-soft); }
.upd-steps li.cur { color: var(--text); font-weight: 600; } .upd-steps li.cur .dot { border-color: var(--accent); color: var(--accent); }
.upd-steps li.cur .spinner { width: 9px; height: 9px; border-width: 1.5px; }
.upd-steps li.bad { color: var(--bad); } .upd-steps li.bad .dot { border-color: var(--bad); }
.upd-log { margin-top: 12px; }
/* API-токены */
.page-lead { color: var(--text-2); margin: 0 0 16px; max-width: 760px; }
.tk-list { display: grid; gap: 12px; }
.card.tk { padding: 16px 18px; transition: opacity .2s; }
.card.tk.off { opacity: .6; }
.tk-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tk-owner { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tk-owner b { font-size: 16px; }
.tk-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 2px 7px; border: 1px solid var(--line-2); border-radius: 99px; }
.tk-switch { margin: 0; align-items: center; }
.tk-switch .lbl { font-size: 13px; color: var(--text-2); min-width: 64px; }
.tk-field { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 6px 6px 12px; }
.tk-field code { flex: 1; min-width: 0; font: 13px/1.5 var(--mono); background: none; border: 0; padding: 0; overflow-wrap: anywhere; color: var(--text); }
.tk-field:hover { border-color: var(--line-2); }
.tk-field.pending code { color: var(--muted); cursor: default; }
.tk-note { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--warn); margin-top: 8px; }
.tk-note .i { flex: none; margin-top: 2px; }
.tk-facts { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); gap: 6px 28px; margin: 12px 0 0; justify-content: start; }
.tk-facts div { min-width: 0; }
.tk-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.tk-facts dd { margin: 0; font-size: 13.5px; color: var(--text-2); }
.tk-warn { color: var(--warn); font-weight: 600; }
.tk-danger { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.tk-danger small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
@media (max-width: 760px) {
  .tk-facts { grid-template-columns: 1fr 1fr; }
  .tk-field { flex-direction: column; align-items: stretch; padding: 10px; }
  .tk-field .btn { justify-content: center; }
  .tk-switch .lbl { display: none; }
}
.tk-more { margin-top: 8px; } .tk-more summary { cursor: pointer; color: var(--accent-text, var(--accent)); font-size: 13.5px; margin-bottom: 10px; }
.tk-list > .card { margin: 0; }
/* настройка колонок */
.col-list { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.col-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.col-item:last-child { border-bottom: 0; }
.col-item .check { flex: 1; }
.col-grip { cursor: grab; color: var(--muted); display: flex; touch-action: none; padding: 2px; }
.col-item.dragging { background: var(--accent-soft); box-shadow: 0 4px 14px rgba(0,0,0,.25); position: relative; z-index: 1; }
.col-item.dragging .col-grip { cursor: grabbing; }
.col-sec { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.col-sec .i { vertical-align: -3px; }
.col-name { flex: 1; }
.col-item { padding: 4px 6px 4px 10px; }
.col-add { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border: 1px dashed var(--line-2); background: transparent; color: var(--text-2); font: inherit; font-size: 13px; }
.col-add:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.col-off { gap: 6px; }
/* метка поставщика */
.src-tag { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.src-tag i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--line-2)); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, transparent) 22%, transparent); }
.color-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.color-pick label { cursor: pointer; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface); transition: transform .15s; }
.color-pick span.none { background: var(--surface-3); display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.color-pick input:checked + span { border-color: var(--text); transform: scale(1.08); }
.cab-box { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 6px 0 12px; background: var(--bg-2); }
.cab-box h4 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.cab-box > p { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.dim { opacity: .45; pointer-events: none; transition: opacity .2s; }
.owner-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; color: var(--accent-text, var(--accent)); background: var(--accent-soft); border-radius: 99px; padding: 1px 8px 1px 6px; vertical-align: 1px; }
