:root {
  --bg: #050506;
  --panel: #0d0d0f;
  --panel2: #111113;
  --card: #0f0f12;
  --line: #1f1f24;
  --line2: #2a2a31;
  --text: #f4f4f6;
  --muted: #8b8b95;
  --muted2: #6a6a74;
  --accent: #ffffff;
  --glow: rgba(120,130,255,.5);
  --ok: #4ade80;
  --bad: #ff5c5c;
  --warn: #f5c451;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", "Inter", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 24px 70px rgba(0,0,0,.6);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(255,255,255,.18); }

/* ---------- Анимированный фон ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 700px at 50% -20%, #131319 0%, #050506 60%, #000 100%); }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; animation: float 22s var(--ease) infinite; }
.o1 { width: 520px; height: 520px; top: -160px; left: -120px; background: radial-gradient(circle, #3a3f7a, transparent 70%); }
.o2 { width: 460px; height: 460px; bottom: -180px; right: -120px; background: radial-gradient(circle, #6a2f6f, transparent 70%); animation-delay: -7s; }
.o3 { width: 400px; height: 400px; top: 40%; left: 55%; background: radial-gradient(circle, #1f5f6a, transparent 70%); animation-delay: -14s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(60px,40px) scale(1.12); }
  66% { transform: translate(-40px,30px) scale(.94); }
}
.grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(900px 600px at 50% 10%, #000 30%, transparent 75%);
}
.noise {
  position: absolute; inset: 0; opacity: .035; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line2); background: #151518; color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn svg { width: 18px; height: 18px; fill: none; }
.btn:hover { border-color: #3a3a44; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { background: #fff; color: #000; border-color: #fff; }
.btn.primary:hover { background: #e6e6ea; box-shadow: 0 8px 26px rgba(255,255,255,.14); }
.btn.ghost { background: rgba(255,255,255,.03); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.icon { padding: 9px; }
.btn.icon.sm { padding: 7px; }

/* ---------- Вход ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(410px, 100%); background: rgba(13,13,16,.82); backdrop-filter: blur(22px);
  border: 1px solid var(--line); border-radius: 26px; padding: 38px 32px;
  box-shadow: var(--shadow); display: grid; gap: 15px; text-align: center;
  animation: pop .55s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
.login-avatar { position: relative; width: 84px; height: 84px; margin: 0 auto 4px; }
.login-avatar img { width: 84px; height: 84px; border-radius: 24px; object-fit: cover; position: relative; z-index: 1; border: 1px solid var(--line2); }
.login-avatar .ring { position: absolute; inset: -6px; border-radius: 30px; background: conic-gradient(from 0deg, #6a6fff, #b84dff, #38d0d8, #6a6fff); animation: spin 6s linear infinite; filter: blur(7px); opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card h1 { margin: 2px 0 0; font-family: var(--display); font-size: 27px; letter-spacing: -.5px; }
.login-card p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 7px; text-align: left; font-size: 12px; color: var(--muted); }
.field input, input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: #000; color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 14px; font: inherit;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #4a4a58; box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.error { color: var(--bad); min-height: 1.1em; font-size: 13px; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(8,8,10,.72); backdrop-filter: blur(16px);
  border-right: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 14px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; border: 1px solid var(--line2); background: #000; }
.side-brand strong { display: block; font-family: var(--display); font-size: 15px; }
.side-brand span { color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2s infinite; }
.dot.off { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

nav { position: relative; display: grid; gap: 3px; flex: 1; align-content: start; }
.nav-indicator { position: absolute; left: 0; width: 3px; height: 40px; border-radius: 3px; background: linear-gradient(#fff, #9aa0ff); transition: transform .32s var(--ease); box-shadow: 0 0 12px rgba(255,255,255,.4); opacity: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; text-align: left; background: transparent;
  color: var(--muted); border: 0; border-radius: 11px; padding: 11px 13px; font: inherit; font-weight: 500; cursor: pointer;
  transition: background .2s, color .2s, transform .15s var(--ease); position: relative;
}
.nav-btn svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.nav-btn svg[stroke], .nav-btn svg path[stroke] { fill: none; }
.nav-btn:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-btn.active { background: rgba(255,255,255,.07); color: #fff; }
.nav-count { margin-left: auto; background: #fff; color: #000; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.logout { margin-top: auto; color: var(--muted2); }
.logout:hover { color: var(--bad); background: rgba(255,92,92,.08); }

.main { padding: 26px 30px 60px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.crumb { color: var(--muted2); font-size: 12px; margin-bottom: 4px; }
.crumb span { opacity: .5; margin: 0 4px; }
.crumb em { color: var(--muted); font-style: normal; }
.top h2 { margin: 0; font-family: var(--display); font-size: 30px; letter-spacing: -.6px; }

.tab { animation: fade .4s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Карточки / сетки ---------- */
.card { background: rgba(15,15,18,.78); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.card h3 { font-family: var(--display); font-size: 17px; margin: 0 0 14px; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.link-btn:hover { color: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 13px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; background: rgba(15,15,18,.8); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: transform .2s var(--ease), border-color .2s; }
.stat:hover { transform: translateY(-3px); border-color: var(--line2); }
.stat::after { content: ""; position: absolute; top: -40%; right: -20%; width: 120px; height: 120px; background: radial-gradient(circle, rgba(255,255,255,.07), transparent 70%); }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat b { display: block; font-family: var(--display); font-size: 30px; margin-top: 8px; }

/* ---------- Списки / события ---------- */
.list { display: grid; gap: 8px; }
.list.tall { max-height: 72vh; overflow: auto; padding-right: 4px; }
.item { background: rgba(9,9,11,.7); border: 1px solid var(--line); border-radius: 13px; padding: 11px 13px; transition: border-color .18s, transform .18s var(--ease); animation: fade .35s var(--ease); }
.item:hover { border-color: var(--line2); transform: translateX(2px); }
.item .meta { display: flex; flex-wrap: wrap; gap: 7px 11px; color: var(--muted); font-size: 11px; margin-bottom: 5px; align-items: center; }
.item .body { font-size: 14px; word-break: break-word; }
.mini-ava { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; vertical-align: middle; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 9px; font-size: 10.5px; font-weight: 600; border: 1px solid var(--line2); color: #cfcfd6; background: rgba(255,255,255,.05); text-transform: lowercase; }
.badge.open { color: var(--ok); border-color: rgba(74,222,128,.3); background: rgba(74,222,128,.08); }
.badge.closed { color: var(--bad); border-color: rgba(255,92,92,.3); background: rgba(255,92,92,.08); }
.badge.reply { color: #9aa0ff; border-color: rgba(154,160,255,.35); background: rgba(154,160,255,.1); }

/* ---------- Таблицы ---------- */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted2); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; background: var(--card); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
a { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.3); transition: border-color .2s; }
a:hover { border-color: #fff; }

.cell-user { display: flex; align-items: center; gap: 9px; }
.cell-user img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line2); }
.cell-user small { display: block; color: var(--muted2); font-size: 11px; }

/* ---------- Сегмент-переключатель ---------- */
.seg { position: relative; display: inline-flex; background: #0c0c0e; border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 18px; }
.seg button { position: relative; z-index: 1; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 20px; border-radius: 10px; cursor: pointer; transition: color .25s; display: flex; align-items: center; gap: 7px; }
.seg button b { background: rgba(255,255,255,.1); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.seg button.active { color: #000; }
.seg button.active b { background: rgba(0,0,0,.15); color: #000; }
.seg-glider { position: absolute; top: 4px; bottom: 4px; left: 4px; width: 50%; background: #fff; border-radius: 10px; transition: transform .3s var(--ease); z-index: 0; }

/* ---------- Стол тикетов ---------- */
.desk { display: grid; grid-template-columns: 330px 1fr; gap: 16px; height: calc(100vh - 210px); min-height: 460px; }
.desk-list { display: flex; flex-direction: column; padding: 14px; overflow: hidden; }
.search { display: flex; align-items: center; gap: 9px; background: #000; border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; margin-bottom: 12px; }
.search svg { width: 17px; height: 17px; stroke: var(--muted); flex: none; }
.search input { border: 0; background: none; padding: 0; }
.search input:focus { box-shadow: none; }
.ticket-list { display: grid; gap: 7px; overflow: auto; align-content: start; padding-right: 4px; }
.tk { display: flex; gap: 11px; align-items: center; background: rgba(9,9,11,.6); border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; cursor: pointer; transition: border-color .18s, background .18s, transform .15s var(--ease); text-align: left; }
.tk:hover { border-color: var(--line2); transform: translateX(2px); }
.tk.active { border-color: #4a4a58; background: rgba(255,255,255,.05); }
.tk img { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; border: 1px solid var(--line2); flex: none; }
.tk-main { min-width: 0; flex: 1; }
.tk-main .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-main .tp { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-num { color: var(--muted2); font-size: 11px; font-family: var(--mono); }

/* ---------- Чат ---------- */
.desk-chat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; padding: 40px; color: var(--muted); }
.chat-empty img { width: 70px; height: 70px; border-radius: 22px; opacity: .5; }
.chat-empty p { max-width: 280px; margin: 0; }
.chat-full { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: fade .3s var(--ease); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-head h3 { margin: 0; font-family: var(--display); font-size: 17px; }
.chat-head-actions { display: flex; gap: 8px; }
.chat-body { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 11px; animation: msgIn .3s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg img.ava { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--line2); }
.msg-c { min-width: 0; flex: 1; }
.msg-top { display: flex; align-items: baseline; gap: 9px; margin-bottom: 3px; }
.msg-top .name { font-weight: 600; font-size: 14px; }
.msg-top .tag { font-size: 9.5px; font-weight: 700; letter-spacing: .4px; padding: 1px 5px; border-radius: 5px; background: #4a4a58; color: #fff; text-transform: uppercase; }
.msg-top .tag.bot { background: #5865f2; }
.msg-top .time { color: var(--muted2); font-size: 11px; }
.msg-text { font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; color: #e3e3e8; }
.msg-att { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 8px; }
.msg-att img { max-width: 260px; max-height: 200px; border-radius: 10px; border: 1px solid var(--line); }
.msg-att a { font-size: 12px; color: var(--muted); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 10px; }
.msg-embed { margin-top: 7px; border-left: 3px solid #4a4a58; background: rgba(255,255,255,.03); border-radius: 0 8px 8px 0; padding: 8px 12px; font-size: 13px; }
.msg-embed .et { font-weight: 600; margin-bottom: 3px; }
.chat-sys { text-align: center; color: var(--muted2); font-size: 12px; padding: 4px; }

/* ---------- Композер ---------- */
.composer { border-top: 1px solid var(--line); padding: 12px 14px 14px; background: rgba(0,0,0,.3); }
.persona-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.persona-ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line2); cursor: pointer; flex: none; transition: transform .15s; }
.persona-ava:hover { transform: scale(1.06); }
.persona-name { flex: 1; min-width: 0; padding: 9px 12px; }
.persona-select { width: auto; min-width: 130px; padding: 9px 10px; }
.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.attach-chip { display: flex; align-items: center; gap: 7px; background: #000; border: 1px solid var(--line2); border-radius: 9px; padding: 5px 8px; font-size: 12px; }
.attach-chip img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.attach-chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.attach-chip button:hover { color: var(--bad); }
.composer-row { display: flex; align-items: flex-end; gap: 9px; }
.composer-row textarea { flex: 1; resize: none; max-height: 160px; line-height: 1.45; padding: 11px 14px; }
.send { align-self: stretch; }
.send svg { width: 20px; height: 20px; }
.composer-hint { color: var(--muted2); font-size: 11px; margin-top: 8px; }

/* ---------- Участники (карточки) ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 10px; }
.person { display: flex; align-items: center; gap: 11px; background: rgba(9,9,11,.6); border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; transition: border-color .18s, transform .15s var(--ease); animation: fade .35s var(--ease); }
.person:hover { border-color: var(--line2); transform: translateY(-2px); }
.person img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line2); }
.person .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .un { color: var(--muted2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.row-between h3 { margin: 0; font-family: var(--display); }
.filters { display: flex; gap: 8px; }
.filters select, .filters input, #member-search { width: auto; min-width: 150px; }

.code { margin: 0; max-height: 76vh; overflow: auto; background: #000; border: 1px solid var(--line); border-radius: 12px; padding: 16px; font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: #bfbfc6; }

/* ---------- Модалка ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-back { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(5px); animation: fade .25s; }
.modal-card { position: relative; width: min(560px, 100%); max-height: 86vh; overflow: auto; animation: pop .35s var(--ease); }
.persona-form { margin: 12px 0 16px; }
.persona-up { display: flex; gap: 14px; }
.persona-up img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; border: 1px solid var(--line2); flex: none; }
.persona-up > div { flex: 1; display: grid; gap: 8px; }
.persona-up-actions { display: flex; gap: 8px; }
.persona-items { display: grid; gap: 8px; }
.persona-chip { display: flex; align-items: center; gap: 11px; background: rgba(9,9,11,.6); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.persona-chip img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.persona-chip .nm { flex: 1; font-weight: 600; }
.persona-chip button { background: none; border: 1px solid var(--line2); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 5px 9px; font-size: 12px; }
.persona-chip button.use:hover { color: #000; background: #fff; }
.persona-chip button.del:hover { color: var(--bad); border-color: var(--bad); }

/* ---------- Тосты ---------- */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 100; display: grid; gap: 10px; }
.toast { background: rgba(18,18,22,.95); backdrop-filter: blur(12px); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); animation: toastIn .3s var(--ease); max-width: 320px; }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ---------- Скроллбары ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26262c; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #35353d; background-clip: padding-box; }

.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line2); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto; }

/* ---------- danger ---------- */
.btn.danger { background: rgba(255,92,92,.12); border-color: rgba(255,92,92,.4); color: #ff8a8a; }
.btn.danger:hover { background: rgba(255,92,92,.2); border-color: #ff5c5c; color: #fff; }

/* ---------- CRM ---------- */
.crm-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.crm-rev { display: flex; flex-direction: column; gap: 4px; padding: 14px 20px; }
.crm-rev span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.crm-rev b { font-family: var(--display); font-size: 26px; }
.pay-select { padding: 5px 8px; border-radius: 8px; font-size: 12px; min-width: 120px; width: auto; }
.pay-select.new { color: var(--muted); }
.pay-select.paid { color: var(--ok); border-color: rgba(74,222,128,.35); }
.pay-select.done { color: #9aa0ff; border-color: rgba(154,160,255,.35); }
.pay-select.cancelled { color: var(--bad); border-color: rgba(255,92,92,.35); }
.amount-input { width: 100px; padding: 6px 9px; border-radius: 8px; font-size: 13px; }

/* ---------- Графики ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; height: 100%; }
.chart .bars { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; justify-content: center; }
.chart .bar { width: 44%; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .5s var(--ease); animation: grow .6s var(--ease); }
.chart .bar.a { background: linear-gradient(#fff, #9aa0ff); }
.chart .bar.b { background: #3a3a44; }
.chart .bar.single { width: 60%; background: linear-gradient(#4ade80, #2f9e58); }
@keyframes grow { from { height: 0 !important; } }
.chart .lbl { color: var(--muted2); font-size: 9px; white-space: nowrap; }
.chart .col:hover .bar { filter: brightness(1.2); }

.rank { display: grid; gap: 8px; }
.rank .r { display: flex; align-items: center; gap: 11px; background: rgba(9,9,11,.6); border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; }
.rank .r .n { width: 22px; height: 22px; border-radius: 6px; background: #1b1b20; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.rank .r .nm { flex: 1; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .r .ct { font-family: var(--mono); color: var(--muted); font-size: 13px; }

/* ---------- Система ---------- */
.svc-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.svc { display: flex; align-items: center; gap: 10px; background: rgba(9,9,11,.6); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.svc .nm { font-weight: 600; }
.svc .st { margin-left: auto; font-size: 12px; }
.bar-meter { height: 7px; border-radius: 4px; background: #1b1b20; overflow: hidden; margin-top: 10px; }
.bar-meter i { display: block; height: 100%; background: linear-gradient(90deg, #4ade80, #9aa0ff); border-radius: 4px; transition: width .6s var(--ease); }
.bar-meter.hot i { background: linear-gradient(90deg, #f5c451, #ff5c5c); }

/* ---------- Шаблоны ---------- */
.tpl-popover { position: absolute; bottom: 100%; left: 14px; right: 14px; margin-bottom: 8px; background: #111115; border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; z-index: 5; padding: 6px; animation: pop .22s var(--ease); }
.tpl-popover .t { padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.tpl-popover .t:hover { background: rgba(255,255,255,.06); }
.tpl-popover .t b { display: block; font-size: 13px; }
.tpl-popover .t span { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { position: relative; }
.tpl-form { display: grid; gap: 8px; margin-bottom: 14px; }

/* ---------- Профиль ---------- */
.modal-card.wide { width: min(760px, 100%); }
.prof-top { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.prof-top img { width: 76px; height: 76px; border-radius: 22px; object-fit: cover; border: 1px solid var(--line2); }
.prof-top .nm { font-family: var(--display); font-size: 22px; }
.prof-top .un { color: var(--muted); font-size: 13px; }
.prof-roles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.role-pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.04); }
.prof-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.prof-box { background: rgba(9,9,11,.5); border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.prof-box h4 { margin: 0 0 9px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.prof-box .mini { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.prof-box .mini:last-child { border: 0; }
.mod-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 6px; border-top: 1px solid var(--line); }
.mod-row input { width: 70px; padding: 7px 9px; }

@media (max-width: 1050px) {
  .desk { grid-template-columns: 1fr; height: auto; }
  .desk-chat { min-height: 520px; }
  .prof-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { border: 0; padding: 0; flex: 1; }
  nav { grid-auto-flow: column; grid-template-columns: none; overflow-x: auto; flex: none; width: 100%; }
  .nav-indicator { display: none; }
  .logout { margin: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}

/* ---------- v9: новые компоненты ---------- */
.ticket-meta { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ticket-meta select, .ticket-meta input { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.ticket-meta #meta-tags { flex: 1; min-width: 120px; }
.meta-note { width: calc(100% - 28px); margin: 8px 14px 0; background: rgba(245,196,81,.06); border: 1px solid rgba(245,196,81,.25); color: var(--text); border-radius: 10px; padding: 8px 10px; font-size: 13px; resize: none; font-family: var(--font); }
.sla-chip { background: rgba(255,92,92,.14); color: #ff8a8a; border: 1px solid rgba(255,92,92,.3); padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.tk.sla { box-shadow: inset 3px 0 0 var(--bad); }
.tk-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.tk-sla { font-size: 11px; color: #ff8a8a; }
.tk-tag { display: inline-block; background: var(--line); color: var(--muted); border-radius: 6px; padding: 1px 6px; font-size: 10px; margin-right: 4px; }
.tag-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 14px 0; }
.tag-chip { background: rgba(154,160,255,.12); border: 1px solid rgba(154,160,255,.35); color: var(--text); border-radius: 8px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.tag-chip:hover { background: rgba(154,160,255,.22); }

.catalog-form, .acc-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.catalog-form input, .acc-form input, .acc-form select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.catalog-form #cat-name { flex: 1; min-width: 140px; }
.catalog-list { display: flex; flex-direction: column; gap: 8px; }
.cat-chip { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
.cat-chip b { flex: 1; }
.cat-chip span { color: var(--ok); font-weight: 600; }
.cat-chip em { color: var(--muted); font-style: normal; font-size: 12px; }
.cat-chip .del { background: none; border: none; color: var(--bad); font-size: 20px; cursor: pointer; }

.search.big { margin: 0; }
.search.big input { font-size: 15px; }
.w-full { width: 100%; }
.row-gap { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.ch-composer { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ch-composer input, .ch-composer textarea { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; font-family: var(--font); font-size: 13px; }

.nav-count.pulse { animation: badgePulse 1.2s var(--ease); background: var(--bad); color: #fff; }
@keyframes badgePulse { 0%,100% { transform: scale(1); } 30% { transform: scale(1.5); } }

.queue-bar { display: flex; gap: 4px; padding: 10px 12px 0; flex-wrap: wrap; }
.q-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.q-btn.active { background: #fff; color: #000; border-color: #fff; }
.menu-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 50; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: rgba(15,15,18,.9); color: #fff; font-size: 18px; }

@media (max-width: 900px) {
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); transform: translateX(-105%); transition: transform .25s var(--ease); z-index: 40; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35; }
  .main { padding-top: 56px; }
  .desk { grid-template-columns: 1fr; }
  .desk-list { max-height: 40vh; }
  .chat-head-actions { flex-wrap: wrap; }
}
