@font-face { font-family: Manrope; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/manrope-cyrillic-wght-normal.woff2) format('woff2-variations'), url(fonts/manrope-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: Manrope; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/manrope-latin-wght-normal.woff2) format('woff2-variations'), url(fonts/manrope-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --bg: #0E1012; --bg2: #121518; --card: #14171A; --card2: #1A1E22; --hover: #1F2429;
  --line: #1F2328; --line2: #23272C; --line3: #2A2F35;
  --text: #ECEFF1; --text2: #C9CFD4; --muted: #9AA3AB; --muted2: #7D868E;
  --err-bg: #2A1517; --err-line: #5A2328; --err: #FF8A8F;
  --warn-bg: #2A2213; --warn-line: #5A4520; --warn: #FFC56B;
  --accent: #5BE37D; --soft: #173322; --ink: #0B1A10;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { color: var(--text); font: 500 14px/1.45 Manrope, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
a { color: var(--text2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }

/* ---------- кнопки и поля ---------- */
.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line3); background: var(--card2); color: var(--text); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn.primary { border: 0; background: var(--accent); color: var(--ink); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #74ea91; }
.btn.danger { border-color: var(--err-line); background: var(--err-bg); color: var(--err); }
.btn.danger:hover:not(:disabled) { background: #351a1d; }
.btn.small { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=search], select, textarea {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line3); background: var(--bg2); outline: none; min-width: 0; }
textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.code-input { letter-spacing: 6px; font-size: 22px; font-weight: 700; text-align: center; height: 52px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.err { color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-card p { margin: 0; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.qr { align-self: center; background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.secret { text-align: center; padding: 10px; border-radius: 10px; background: var(--bg2); border: 1px dashed var(--line3); user-select: all; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 4px 10px 16px; }
.nav { height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 10px; padding: 0 12px; text-align: left; width: 100%; }
.nav:hover { background: var(--card); color: var(--text); }
.nav[aria-current=page] { background: var(--hover); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .badge { margin-left: auto; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.main { padding: 28px 32px 48px; min-width: 0; max-width: 1200px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 24px; }
.head p { margin: 4px 0 0; color: var(--muted); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--ink); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--card2); border: 1px solid var(--line3); color: var(--text2); }
.tag.red { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.tag.yellow { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.tag.green { background: var(--soft); border-color: #24502f; color: var(--accent); }

/* ---------- карточки и таблицы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .k { color: var(--muted); font-size: 13px; }
.two { grid-template-columns: 1fr 1fr; }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item.click { cursor: pointer; border-radius: 10px; padding: 12px 10px; }
.item.click:hover { background: var(--card2); }
.item .t { font-weight: 700; }
.item .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.face { width: 36px; height: 36px; border-radius: 8px; background: var(--card2); flex-shrink: 0; image-rendering: pixelated; object-fit: cover; }
.face.big { width: 64px; height: 64px; border-radius: 12px; }
.text-block { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.kv div:nth-child(odd) { color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow: auto; }
.msg { padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.msg.hl { border-color: var(--warn-line); background: var(--warn-bg); }
.msg.sys { background: transparent; border-style: dashed; color: var(--muted); }
.msg .who { font-weight: 700; flex-shrink: 0; }
.msg .body { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .at { color: var(--muted2); font-size: 12px; flex-shrink: 0; }
.bgimg { max-width: 100%; max-height: 180px; border-radius: 10px; border: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { height: 40px; border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: 0 12px; box-shadow: inset 0 -2px 0 transparent; }
.tab[aria-selected=true] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.empty { color: var(--muted); padding: 24px 4px; text-align: center; }
.more { margin-top: 12px; }
.back { margin-bottom: 14px; }

/* ---------- диалог ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 6, 7, .72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line3); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog p { margin: 0; color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 360px; padding: 12px 16px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line3); box-shadow: 0 12px 32px rgba(0,0,0,.5); z-index: 60; }
.toast.bad { border-color: var(--err-line); color: var(--err); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .brand { display: none; }
  .side .me { margin: 6px 0 0; padding: 8px 4px 0; width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .nav { width: auto; }
  .main { padding: 20px 16px 40px; }
  .two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- откат ---------- */
.chk { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.chk-off { width: 18px; flex-shrink: 0; }
label.item { cursor: pointer; }
.item.off { cursor: default; opacity: .6; }
.item .sub.warn { color: var(--warn); }
