/* =========================================================
   TG Panel — дизайн-система
   ========================================================= */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --border: #e4e8ee;
  --border-strong: #d3d9e2;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent: #2f6fed;
  --accent-hover: #2159d6;
  --accent-soft: #eaf1fe;
  --accent-text: #ffffff;
  --good: #15803d;   --good-soft: #e3f6ea;
  --warn: #b45309;   --warn-soft: #fdf1dc;
  --bad: #dc2626;    --bad-soft: #fde8e8;
  --violet: #7c3aed; --violet-soft: #f1eafe;
  --sb-bg: #0f1623;
  --sb-text: #a8b3c4;
  --sb-text-strong: #ffffff;
  --sb-hover: rgba(255, 255, 255, .06);
  --sb-active: rgba(79, 140, 255, .16);
  --sb-border: rgba(255, 255, 255, .06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 4px 10px rgba(15, 23, 42, .06);
  --ring: 0 0 0 3px rgba(47, 111, 237, .22);
  --radius: 12px;
  --radius-sm: 8px;
  --sbw: 252px;
  --topbar: 60px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}

/* тёмная тема: по системе (если не выбрана светлая) и принудительно */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1017; --surface: #121923; --surface-2: #161e2a; --surface-3: #1b2431;
    --border: #232d3b; --border-strong: #2f3b4c;
    --text: #e6ebf2; --text-2: #b4bfcd; --muted: #8592a3;
    --accent: #4f8cff; --accent-hover: #6b9fff; --accent-soft: rgba(79, 140, 255, .14); --accent-text: #fff;
    --good: #4ade80; --good-soft: rgba(74, 222, 128, .12);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
    --bad: #f87171;  --bad-soft: rgba(248, 113, 113, .12);
    --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .14);
    --sb-bg: #0a0e15; --sb-border: rgba(255, 255, 255, .05);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(79, 140, 255, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1017; --surface: #121923; --surface-2: #161e2a; --surface-3: #1b2431;
  --border: #232d3b; --border-strong: #2f3b4c;
  --text: #e6ebf2; --text-2: #b4bfcd; --muted: #8592a3;
  --accent: #4f8cff; --accent-hover: #6b9fff; --accent-soft: rgba(79, 140, 255, .14); --accent-text: #fff;
  --good: #4ade80; --good-soft: rgba(74, 222, 128, .12);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --bad: #f87171;  --bad-soft: rgba(248, 113, 113, .12);
  --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .14);
  --sb-bg: #0a0e15; --sb-border: rgba(255, 255, 255, .05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(79, 140, 255, .3);
  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: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
small { font-size: 12px; }
.i { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.mt-s { margin-top: 10px; }
.strike { text-decoration: line-through; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack-sm { display: grid; gap: 8px; justify-items: start; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: var(--sbw) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.sb-collapsed .app { grid-template-columns: 72px minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sb-bg); color: var(--sb-text); border-right: 1px solid var(--sb-border);
  overflow: hidden; z-index: 40;
}
.sb-brand { display: flex; align-items: center; gap: 12px; height: var(--topbar); padding: 0 18px; color: var(--sb-text-strong); border-bottom: 1px solid var(--sb-border); }
.sb-brand:hover { color: var(--sb-text-strong); }
.sb-brand b { display: block; font-size: 15px; }
.sb-brand small { display: block; color: var(--sb-text); font-size: 11.5px; margin-top: -2px; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #4f8cff, #2f6fed 55%, #6d4aff); color: #fff;
  box-shadow: 0 4px 12px -2px rgba(47, 111, 237, .55);
}
.logo.lg { width: 40px; height: 40px; border-radius: 12px; }
.sb-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sb-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5f6b7d; padding: 14px 10px 6px; }
.sb-section:first-child { padding-top: 4px; }
.sb-nav a, .sb-link {
  position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
  border-radius: 9px; color: var(--sb-text); font-weight: 500; white-space: nowrap;
  background: none; border: 0; font: inherit; font-weight: 500; width: 100%; cursor: pointer; text-align: left;
}
.sb-nav a:hover, .sb-link:hover { background: var(--sb-hover); color: var(--sb-text-strong); }
.sb-nav a.active { background: var(--sb-active); color: var(--sb-text-strong); }
.sb-nav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #4f8cff; }
.sb-nav a.active .i { color: #7aa8ff; }
.sb-foot { padding: 12px; border-top: 1px solid var(--sb-border); }
.sb-foot form { margin: 0; }

.sb-collapsed .sb-label { display: none; }
.sb-collapsed .sb-brand { padding: 0; justify-content: center; }
.sb-collapsed .sb-nav a, .sb-collapsed .sb-link { justify-content: center; padding: 0; }
.sb-collapsed .sb-nav { padding: 12px 14px; }
.sb-collapsed .sb-nav a.active::before { left: -14px; }
.sb-overlay { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.tb-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb { color: var(--muted); font-weight: 500; }
.crumb:hover { color: var(--text); }
.tb-search {
  position: relative; margin-left: auto; width: min(380px, 40vw);
  display: flex; align-items: center; color: var(--muted);
}
.tb-search .i { position: absolute; left: 11px; pointer-events: none; }
.tb-search input { padding-left: 34px !important; padding-right: 34px !important; background: var(--surface-2) !important; height: 36px; }
.tb-search kbd {
  position: absolute; right: 8px; font: 11px var(--mono); color: var(--muted);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface);
}
.tb-actions { display: flex; align-items: center; gap: 6px; }

.content { padding: 24px 28px 48px; width: 100%; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 550; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(47, 111, 237, .3); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; height: 40px; }
.btn:disabled { opacity: .7; cursor: progress; }
.danger-text { color: var(--bad) !important; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.link-sm { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; font-weight: 500; }
.link-sm:hover { text-decoration: underline; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* тема / fullscreen иконки */
.th-icon, .fs-off { display: none; }
:root[data-theme-choice="system"] .th-system,
:root[data-theme-choice="light"] .th-light,
:root[data-theme-choice="dark"] .th-dark { display: inline-flex; }
:root:not([data-theme-choice]) .th-system { display: inline-flex; }
.is-fullscreen .fs-on { display: none; }
.is-fullscreen .fs-off { display: inline-flex; }

/* ---------- формы ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--text-2); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; height: 38px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 64px; line-height: 1.45; }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:disabled, select:disabled { opacity: .55; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 13.5px; cursor: pointer; color: var(--text); font-weight: 450; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.input-prefix { display: flex; }
.input-prefix span { display: grid; place-items: center; padding: 0 11px; background: var(--surface-3); border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--muted); }
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }
.input-action { position: relative; display: block; }
.input-action input { padding-right: 40px !important; }
.input-action .icon-btn { position: absolute; right: 4px; top: 4px; }
.input-icon { position: relative; display: flex; align-items: center; color: var(--muted); }
.input-icon .i { position: absolute; left: 10px; pointer-events: none; }
.input-icon input { padding-left: 32px !important; height: 34px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: .4em; text-align: center; height: 52px !important; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 18px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); min-height: 56px; }
.card-b { padding: 18px; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-f select { width: auto; min-width: 260px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-2 > .card, .grid-2 > .stack > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
@media (min-width: 1600px) { .split { grid-template-columns: minmax(0, 1fr) 380px; } }
.split > .card { margin-bottom: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 4px; }

/* ---------- статистика ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat.attention { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.stat-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.stat-ic.good { background: var(--good-soft); color: var(--good); }
.stat-ic.warn { background: var(--warn-soft); color: var(--warn); }
.stat-ic.bad { background: var(--bad-soft); color: var(--bad); }
.stat-ic.violet { background: var(--violet-soft); color: var(--violet); }
.stat-v { font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  position: sticky; top: 0; text-align: left; font-weight: 550; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .end { text-align: right; width: 1%; white-space: nowrap; }
.tbl td form { margin: 0; }
.row-link { cursor: pointer; }
.is-current td { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.is-muted { opacity: .6; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; height: 34px; min-width: 160px; }
.filters .input-icon input { width: 200px; }

/* ---------- люди и аватары ---------- */
.ava { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-3); }
.ava.sm { width: 30px; height: 30px; }
.ava.xl { width: 72px; height: 72px; }
.who { display: flex; align-items: center; gap: 11px; color: var(--text); min-width: 0; }
.who:hover { color: var(--text); }
.who b, .person b { font-weight: 600; }
.tbl .who b, .tbl .who small, .tbl .person > span:last-child { white-space: nowrap; }
.m-only { display: none; }
.who small, .person small { display: block; }
.who > span, .person > span:last-child { min-width: 0; line-height: 1.3; }
.pava {
  --h: 210; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: hsl(var(--h) 65% 92%); color: hsl(var(--h) 55% 32%);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
:root[data-theme="dark"] .pava { background: hsl(var(--h) 45% 22%); color: hsl(var(--h) 80% 78%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pava { background: hsl(var(--h) 45% 22%); color: hsl(var(--h) 80% 78%); } }
.pava.lg { width: 44px; height: 44px; font-size: 15px; }
.pava.xxl { width: 72px; height: 72px; font-size: 24px; }
.person { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.person:hover { color: var(--text); }
.person.sm { gap: 6px; font-size: 12.5px; }
.person.sm .pava { width: 20px; height: 20px; font-size: 8.5px; }
.person.lg .pava { width: 36px; height: 36px; font-size: 13px; }
.dev-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 550; white-space: nowrap; vertical-align: middle;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.badge.good, .badge.warn, .badge.bad { border-color: transparent; }
.badge.good::before, .badge.warn::before, .badge.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.premium { background: linear-gradient(90deg, #8b5cf6, #ec4899); color: #fff; border: 0; }
.badge.sm { height: 19px; font-size: 11px; padding: 0 6px; }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs .tab-link {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.tabs button:hover, .tabs .tab-link:hover { color: var(--text); }
.tabs .tab-link { margin-left: auto; color: var(--accent); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent); }

/* ---------- шапка профиля ---------- */
.profile-head { display: flex; align-items: center; gap: 20px; padding: 20px 22px; flex-wrap: wrap; }
.ph-main { flex: 1; min-width: 240px; }
.ph-main h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ph-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; color: var(--text-2); }
.ph-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.ph-meta .i { color: var(--muted); }
.ph-side { padding-left: 20px; border-left: 1px solid var(--border); }
.ph-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.ph-stats { display: flex; gap: 8px; }
.ph-stats > div { display: grid; text-align: center; padding: 10px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); min-width: 90px; }
.ph-stats b { font-size: 18px; }
.ph-stats span { font-size: 12px; color: var(--muted); }

.assignee { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.assignee a { color: var(--text); }
.empty-a { color: var(--muted); border-style: dashed; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }

.photo-row { display: flex; gap: 18px; align-items: center; }

.secret { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.secret-h { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.secret-h form { margin: 0; }
.secret-v { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.secret-v code { flex: 1; font: 15px var(--mono); letter-spacing: .03em; user-select: all; word-break: break-all; }

/* ---------- лента событий ---------- */
.feed { list-style: none; margin: 0; padding: 6px 0; }
.feed li { display: flex; gap: 12px; padding: 10px 18px; }
.feed li + li { border-top: 1px solid var(--border); }
.feed-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; background: var(--surface-3); color: var(--text-2); }
.feed-ic.good { background: var(--good-soft); color: var(--good); }
.feed-ic.warn { background: var(--warn-soft); color: var(--warn); }
.feed-ic.bad { background: var(--bad-soft); color: var(--bad); }
.feed-ic.accent { background: var(--accent-soft); color: var(--accent); }
.feed-body { min-width: 0; font-size: 13px; }
.feed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.feed-meta time { white-space: nowrap; }
.ev { display: inline-flex; align-items: center; gap: 8px; }
.ev .feed-ic { width: 24px; height: 24px; border-radius: 7px; }

/* ---------- таймлайн ---------- */
.timeline { list-style: none; margin: 0; padding: 14px 18px 6px; }
.timeline li { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .pava { width: 32px; height: 32px; font-size: 11px; position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--surface); }
.timeline li > div { flex: 1; min-width: 0; }
.timeline li.now .pava { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--good); }
.timeline a { color: var(--text); }

/* ---------- сообщения 777000 ---------- */
.msgs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.msgs li { padding: 14px 18px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.msgs time { font-size: 12px; color: var(--muted); }
.pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; margin-top: 4px; max-height: 160px; overflow: auto; }

/* ---------- массовые ---------- */
.bulk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.bulk > .card { margin: 0; }
.pick-list { max-height: 62vh; overflow-y: auto; padding: 6px; }
.pick { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick:has(input:checked) { background: var(--accent-soft); }
.pick b { display: block; font-weight: 600; font-size: 13.5px; }
.pick small { display: block; }
.options { display: grid; gap: 8px; }
.option { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover { border-color: var(--border-strong); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--ring); }
.option b { display: block; }
.option small { display: block; }
.opt-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.opt-ic.warn { background: var(--warn-soft); color: var(--warn); }
.opt-fields { padding: 14px 14px 4px; margin: -2px 0 6px 18px; border-left: 2px solid var(--accent); }

/* ---------- мастер добавления ---------- */
.wizard { max-width: 460px; margin: 4vh auto 0; }
.wizard .card h1 { margin-bottom: 6px; }
.wizard .card p { margin-bottom: 20px; }
.wizard .card { padding: 26px; }
.steps { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 6px; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.steps li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); font-size: 12px; background: var(--surface); flex-shrink: 0; }
.steps li.active { color: var(--text); }
.steps li.active span { border-color: var(--accent); background: var(--accent); color: #fff; }
.steps li.done span { border-color: var(--good); background: var(--good); color: #fff; }

/* ---------- пусто / алерты ---------- */
.empty { text-align: center; padding: 48px 20px; display: grid; justify-items: center; gap: 10px; }
.empty.sm { padding: 28px 20px; }
.empty-ic { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.empty .btn { margin-top: 8px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); }
.alert.bad div { color: var(--text); }

/* ---------- уведомления ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good);
  border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .25s ease;
}
.toast > .i { color: var(--good); margin-top: 1px; }
.toast span { flex: 1; }
.toast.err { border-left-color: var(--bad); }
.toast.err > .i { color: var(--bad); }
.toast.info { border-left-color: var(--accent); }
.toast.info > .i { color: var(--accent); }
.toast.out { opacity: 0; transform: translateX(16px); transition: .25s; }
.toast-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 5px; line-height: 0; font-size: 16px; }
.toast-x:hover { background: var(--surface-3); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- модалки ---------- */
.modal { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(8, 12, 20, .5); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .2s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-h h2 { font-size: 16px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ---------- страница входа ---------- */
.auth { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(0, 1.2fr); min-height: 100vh; }
.auth-side {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; overflow: hidden;
  background: radial-gradient(120% 80% at 0% 0%, #2a4fb8 0%, transparent 60%), radial-gradient(90% 70% at 100% 100%, #5b3bd6 0%, transparent 55%), #0d1424;
  color: #dbe4f3;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 650; color: #fff; }
.auth-pitch h2 { font-size: 30px; line-height: 1.2; color: #fff; font-weight: 700; display: block; max-width: 380px; margin-bottom: 22px; }
.auth-pitch ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.auth-pitch li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.auth-pitch .i { color: #8fb4ff; }
.auth-foot { font-size: 13px; color: #8b98b0; }
.auth-main { position: relative; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card p { margin-bottom: 26px; }
.auth-card .btn-block { margin-top: 8px; height: 44px; }
.auth-card input { height: 44px !important; }
.auth-theme { position: absolute; top: 16px; right: 16px; }

/* ---------- адаптив ---------- */
.only-mobile { display: none; }
@media (max-width: 1024px) {
  .grid-2, .bulk { grid-template-columns: 1fr; }
  .ph-side { border-left: 0; padding-left: 0; }
}
@media (max-width: 900px) {
  .app, .sb-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sb-open .sidebar { transform: none; }
  .sb-collapsed .sb-label { display: initial; }
  .sb-collapsed .sb-brand { padding: 0 18px; justify-content: flex-start; }
  .sb-collapsed .sb-nav a, .sb-collapsed .sb-link { justify-content: flex-start; padding: 0 12px; }
  .sb-open .sb-overlay { display: block; position: fixed; inset: 0; background: rgba(8, 12, 20, .45); z-index: 35; }
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none; }
  .tb-search { display: none; }
  .tb-title { flex: 1; }
  .content { padding: 18px 16px 40px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 640px) {
  .form-row, .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .topbar { padding: 0 10px; gap: 6px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ic { width: 36px; height: 36px; }
  .stat-v { font-size: 20px; }
  .filters, .filters select, .filters .input-icon, .filters .input-icon input { width: 100%; }
  .ph-stats { width: 100%; }
  .ph-stats > div { flex: 1; min-width: 0; padding: 8px; }
  .card-f select { min-width: 0; width: 100%; }
  .msgs { grid-template-columns: 1fr; }
  .page-head .row { width: 100%; }
  .page-head .row > * { flex: 1; }
  .page-head .row .btn { width: 100%; }

  /* таблица аккаунтов → карточки */
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody { display: block; }
  .tbl-cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .tbl-cards tbody tr:last-child { border-bottom: 0; }
  .tbl-cards td { padding: 0; border: 0; }
  .tbl-cards .c-hide { display: none; }
  .tbl-cards .c-emp { grid-column: 1 / -1; padding-left: 47px; }
  .tbl-cards .who b, .tbl-cards .who small { white-space: normal; }
  .tbl-cards .c-sec { grid-row: 1; grid-column: 2; text-align: right; align-self: center; }
  .m-only { display: inline; }
}

/* ---------- чаты ---------- */
.content:has(.chat-app) { padding-bottom: 24px; }
.chat-app {
  --bubble-in: var(--surface); --bubble-out: #e2edff; --chat-bg: var(--surface-2);
  display: grid; grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100dvh - var(--topbar) - 48px); min-height: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
:root[data-theme="dark"] .chat-app { --bubble-in: #1b2431; --bubble-out: #1e3a6e; --chat-bg: #0e141d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat-app { --bubble-in: #1b2431; --bubble-out: #1e3a6e; --chat-bg: #0e141d; } }

.chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.cl-head { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.cl-head .input-icon input { width: 100%; }
.dlg { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.dlg-item { display: flex; gap: 11px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.dlg-item:hover { background: var(--surface-3); color: var(--text); }
.dlg-item.active { background: var(--accent); color: var(--accent-text); }
.dlg-item.active .muted, .dlg-item.active time, .dlg-item.active .you, .dlg-item.active .dlg-prev { color: color-mix(in srgb, var(--accent-text) 82%, transparent); }
.dlg-item.flash { animation: dlg-flash 1.2s ease; }
@keyframes dlg-flash { from { background: var(--accent-soft); } }
.dlg-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.dlg-top, .dlg-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dlg-top b { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; font-weight: 600; }
.dlg-top b > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-top time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.dlg-prev { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { color: var(--text-2); }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-text); font-size: 11.5px; font-weight: 700; flex-shrink: 0; }
.unread.mute { background: var(--muted); }
.dlg-item.active .unread { background: var(--accent-text); color: var(--accent); }
.pava.tg { background: linear-gradient(135deg, #37aee2, #1e96c8); color: #fff; }

.chat-view { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.cv-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); }
.cv-title { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.cv-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.live .i { color: var(--muted); }
.live.on .i { color: var(--good); animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .35; } }
.card-h h2 .live { margin-left: 4px; }

.cv-body { flex: 1; overflow-y: auto; padding: 12px clamp(12px, 4%, 48px) 16px; overscroll-behavior: contain; }
.load-more { text-align: center; padding: 4px 0 10px; }
.msgs-list { display: flex; flex-direction: column; gap: 3px; max-width: 920px; margin: 0 auto; }
.day-sep { text-align: center; margin: 12px 0 8px; position: sticky; top: 0; z-index: 1; }
.day-sep span { display: inline-block; padding: 3px 11px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); box-shadow: var(--shadow-sm); }
.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: min(560px, 78%); padding: 7px 11px 6px; border-radius: 14px;
  background: var(--bubble-in); border: 1px solid var(--border); box-shadow: var(--shadow-sm); min-width: 0;
}
.msg.in .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble { background: var(--bubble-out); border-color: transparent; border-bottom-right-radius: 5px; }
.bubble.bare { background: none; border: 0; box-shadow: none; padding: 0; }
.msg.new .bubble { animation: msg-in .3s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.hl .bubble { box-shadow: 0 0 0 2px var(--accent); }
.msg-from { font-size: 12.5px; font-weight: 650; color: hsl(var(--h) 60% 42%); margin-bottom: 2px; }
:root[data-theme="dark"] .msg-from { color: hsl(var(--h) 75% 70%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-from { color: hsl(var(--h) 75% 70%); } }
.msg-fwd { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); margin-bottom: 3px; }
.msg-reply { display: flex; align-items: center; gap: 5px; margin: 1px 0 5px; padding: 3px 8px; border-left: 3px solid var(--accent); border-radius: 4px; background: color-mix(in srgb, var(--accent) 9%, transparent); font-size: 12.5px; color: var(--text-2); }
.msg-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.msg-text a { text-decoration: underline; text-underline-offset: 2px; }
.msg-media { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); padding: 2px 0; }
.msg-img-link { display: block; margin: 2px -5px 4px; }
.msg-img { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; background: var(--surface-3); min-height: 60px; min-width: 120px; object-fit: cover; }
.msg-img.sticker { max-width: 160px; max-height: 160px; background: none; min-height: 0; min-width: 0; object-fit: contain; }
.msg-meta { float: right; margin: 6px 0 -3px 12px; font-size: 11px; color: var(--muted); line-height: 1; white-space: nowrap; }
.msg-service { text-align: center; margin: 6px 0; }
.msg-service span { display: inline-block; padding: 3px 11px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 14%, transparent); font-size: 12.5px; color: var(--text-2); }

.code-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 2px; padding: 6px 12px; border-radius: 9px;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); color: var(--accent);
  font: inherit; font-size: 18px; font-weight: 700; letter-spacing: .12em; cursor: pointer;
}
.code-chip:hover { border-style: solid; }
.msgs .code-chip { display: flex; width: max-content; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; min-height: 40px; max-height: 180px; resize: none; padding: 9px 12px; }
.send-btn { width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.composer-note { padding: 12px 16px; text-align: center; font-size: 13px; background: var(--surface); border-top: 1px solid var(--border); }
.cv-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; }
.cv-empty .alert { max-width: 520px; text-align: left; }

/* уведомление о коде входа */
.toast.code { border-left-color: var(--accent); flex-wrap: wrap; }
.toast.code > .i { color: var(--accent); }
.toast-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.toast-body b { font-size: 13.5px; }
.toast-body small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .code-chip { margin: 6px 0 0; font-size: 20px; }
.toast a.link-sm { margin-top: 4px; }

@media (max-width: 900px) {
  .content:has(.chat-app) { padding: 0; }
  .chat-app { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--topbar)); border: 0; border-radius: 0; box-shadow: none; }
  .chat-app.has-chat .chat-list { display: none; }
  .chat-app:not(.has-chat) .chat-view { display: none; }
  .chat-list { border-right: 0; }
  .bubble { max-width: 88%; }
  .live > span { display: none; }
  .cv-head { padding: 8px 10px; gap: 8px; }
}
