/* Trip Advance — веб-клиент специалиста. Чистый CSS, без сборки. */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e3e6ea;
  --text: #1a1d21;
  --text-dim: #6b7280;
  --primary: #2563eb;
  --primary-2: #4f46e5;
  --primary-ink: #ffffff;
  --accent: #2563eb;
  --accent-grad: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  --danger: #e11d48;
  --success: #16a34a;
  --warn: #e8920c;
  --bubble-in: #ffffff;
  --bubble-out: #dbeafe;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --radius: 14px;
  --topbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Чат: обои, стекло, пузыри */
  --chat-bg: linear-gradient(180deg, #cfe0f2 0%, #e6edf6 55%, #eef2f8 100%);
  --chat-doodle: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22160%22%20height%3D%22160%22%20viewBox%3D%220%200%20160%20160%22%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%231a3a5c%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20opacity%3D%220.5%22%3E%3Cpath%20d%3D%22M28%2020c0-6%205-11%2011-11s11%205%2011%2011c0%208-11%2018-11%2018S28%2028%2028%2020z%22/%3E%3Ccircle%20cx%3D%2239%22%20cy%3D%2220%22%20r%3D%223.5%22/%3E%3Crect%20x%3D%2296%22%20y%3D%2214%22%20width%3D%2230%22%20height%3D%2221%22%20rx%3D%225%22/%3E%3Cpath%20d%3D%22M100%2040l6-6%22/%3E%3Cpath%20d%3D%22M18%2092l26-10-10%2026-4-11z%22/%3E%3Ccircle%20cx%3D%22118%22%20cy%3D%2286%22%20r%3D%2210%22/%3E%3Cpath%20d%3D%22M118%2072v-5M118%20100v5M104%2086h-5M132%2086h5M108%2076l-3-3M128%2076l3-3M108%2096l-3%203M128%2096l3%203%22/%3E%3Cpath%20d%3D%22M70%20118l40-16-16%2040-6-16z%22/%3E%3Cpath%20d%3D%22M136%20120l5%2010%2011%201-8%208%202%2011-10-5-10%205%202-11-8-8%2011-1z%22/%3E%3Cpath%20d%3D%22M40%20140c-8-6-14-11-14-18%200-4%203-7%207-7%203%200%205%202%207%204%202-2%204-4%207-4%204%200%207%203%207%207%200%207-6%2012-14%2018z%22/%3E%3Crect%20x%3D%2270%22%20y%3D%2220%22%20width%3D%2230%22%20height%3D%2222%22%20rx%3D%225%22/%3E%3Cpath%20d%3D%22M70%2025l15%2010%2015-10%22/%3E%3C/g%3E%3C/svg%3E");
  --bubble-out-grad: linear-gradient(180deg, #4d8efb 0%, #3f7ff0 100%);
  --bubble-out-tail: #3f7ff0;
  --glass-bg: rgba(247,249,252,.72);
  --glass-border: rgba(180,195,215,.5);
  --input-bg: rgba(255,255,255,.9);
  --author-color: var(--primary);
}
html[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2230;
  --border: #2a313c;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --primary: #3b82f6;
  --primary-2: #6366f1;
  --accent: #3b82f6;
  --accent-grad: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  /* Чат тёмный — аутентичная палитра Telegram */
  --chat-bg: linear-gradient(180deg, #0e1621 0%, #131c28 100%);
  --chat-doodle: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22160%22%20height%3D%22160%22%20viewBox%3D%220%200%20160%20160%22%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%238fb4d6%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20opacity%3D%220.5%22%3E%3Cpath%20d%3D%22M28%2020c0-6%205-11%2011-11s11%205%2011%2011c0%208-11%2018-11%2018S28%2028%2028%2020z%22/%3E%3Ccircle%20cx%3D%2239%22%20cy%3D%2220%22%20r%3D%223.5%22/%3E%3Crect%20x%3D%2296%22%20y%3D%2214%22%20width%3D%2230%22%20height%3D%2221%22%20rx%3D%225%22/%3E%3Cpath%20d%3D%22M100%2040l6-6%22/%3E%3Cpath%20d%3D%22M18%2092l26-10-10%2026-4-11z%22/%3E%3Ccircle%20cx%3D%22118%22%20cy%3D%2286%22%20r%3D%2210%22/%3E%3Cpath%20d%3D%22M118%2072v-5M118%20100v5M104%2086h-5M132%2086h5M108%2076l-3-3M128%2076l3-3M108%2096l-3%203M128%2096l3%203%22/%3E%3Cpath%20d%3D%22M70%20118l40-16-16%2040-6-16z%22/%3E%3Cpath%20d%3D%22M136%20120l5%2010%2011%201-8%208%202%2011-10-5-10%205%202-11-8-8%2011-1z%22/%3E%3Cpath%20d%3D%22M40%20140c-8-6-14-11-14-18%200-4%203-7%207-7%203%200%205%202%207%204%202-2%204-4%207-4%204%200%207%203%207%207%200%207-6%2012-14%2018z%22/%3E%3Crect%20x%3D%2270%22%20y%3D%2220%22%20width%3D%2230%22%20height%3D%2222%22%20rx%3D%225%22/%3E%3Cpath%20d%3D%22M70%2025l15%2010%2015-10%22/%3E%3C/g%3E%3C/svg%3E");
  --bubble-out-grad: linear-gradient(135deg, #2b5278 0%, #2f6ea5 100%);
  --bubble-out-tail: #2b5278;
  --glass-bg: rgba(23,33,43,.72);
  --glass-border: rgba(60,80,100,.5);
  --input-bg: rgba(30,42,56,.9);
  --author-color: #7cc0ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.4;
  overflow: hidden;
}
.hidden { display: none !important; }
input, textarea, button, select { font-family: inherit; font-size: 15px; }
button { cursor: pointer; }
a { color: var(--primary); }

/* ─────────── Логин ─────────── */
#login-screen { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; }
.login-card {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 24px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 4px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { margin: 0; text-align: center; font-size: 22px; }
.login-card .sub { margin: 0 0 8px; text-align: center; color: var(--text-dim); }
.login-card input {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button {
  padding: 13px; border: none; border-radius: 10px; background: var(--primary);
  color: var(--primary-ink); font-weight: 600;
}
.login-card button:disabled { opacity: .6; }
.error { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; }

/* ─────────── Shell ─────────── */
#app-screen { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: calc(var(--topbar-h) + var(--safe-top)); padding-top: var(--safe-top);
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding-left: 6px; padding-right: 6px;
  background: var(--primary); color: #fff; box-shadow: var(--shadow); z-index: 20;
}
.icon-btn {
  background: transparent; border: none; color: inherit;
  width: 40px; height: 40px; border-radius: 10px; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255,255,255,.18); }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
#topbar-main { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 82vw;
  background: var(--surface); z-index: 40; box-shadow: 2px 0 16px rgba(0,0,0,.25);
  transform: translateX(-102%); transition: transform .22s ease;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; background: var(--primary); color: #fff; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex: 0 0 auto;
}
.drawer-name { font-weight: 600; }
.drawer-role { font-size: 12px; opacity: .85; text-transform: capitalize; }
.nav-items { flex: 1; overflow-y: auto; padding: 8px; }
.nav-item { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 10px; color: var(--text); font-size: 15px; }
.nav-item .nav-ic { font-size: 20px; width: 24px; text-align: center; }
.nav-item.active { background: var(--surface-2); color: var(--primary); font-weight: 600; }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }
.drawer-logout { margin: 8px 14px calc(14px + var(--safe-bottom)); padding: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--danger); font-weight: 600; }

/* ─────────── Screen host ─────────── */
.screen-host { flex: 1; min-height: 0; overflow: hidden; position: relative; display: flex; }
.pane { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pane-pad { padding: 12px; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-dim); }
.loading { padding: 28px; text-align: center; color: var(--text-dim); }

.card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
.list-item { background: var(--surface); padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.list-item:active { background: var(--surface-2); }
/* Обращения — карточка в стиле мессенджера */
.th-item { align-items: center; padding: 11px 14px; }
.th-av { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .3px; box-shadow: 0 2px 6px rgba(0,0,0,.14); }
.th-bottom { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.th-bottom .li-preview { flex: 1; min-width: 0; margin-top: 0; }
.th-bottom .badge { flex: 0 0 auto; }
/* Тикеты — «заявочный» вид: квадратная плитка со статус-иконкой + цветная полоса статуса */
.tk-item { align-items: center; padding: 11px 14px; border-left: 4px solid var(--border); }
.tk-tile { width: 46px; height: 46px; border-radius: 13px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.tk-num { font-weight: 700; color: var(--text); }
.tk-bottom { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tk-prev { flex: 1; min-width: 0; margin: 0; }
.tk-new { border-left-color: var(--warn); }
.tk-new .tk-tile { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent); }
.tk-open { border-left-color: var(--accent); }
.tk-open .tk-tile { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.tk-in_progress { border-left-color: #6d4ad6; }
.tk-in_progress .tk-tile { background: color-mix(in srgb, #6d4ad6 16%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, #6d4ad6 32%, transparent); }
.tk-closed { border-left-color: var(--success); }
.tk-closed .tk-tile { background: color-mix(in srgb, var(--success) 14%, var(--surface)); }
.tk-closed .li-title { opacity: .85; }
/* Обращения с новыми сообщениями — выделяем и поднимаем наверх (сортировка в JS) */
.list-item.unread { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-left: 3px solid var(--accent); padding-left: 11px; }
.list-item.unread .li-title { font-weight: 800; }
.threads-newhint { padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-bottom: 1px solid var(--border); }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-time { font-size: 12px; color: var(--text-dim); flex: 0 0 auto; }
.li-sub { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Чип мессенджера клиента (Telegram / MAX) */
.ch-chip { display: inline-block; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 2px 6px; border-radius: 6px; vertical-align: middle; margin-right: 2px; letter-spacing: .2px; }
.ch-chip.ch-tg { background: color-mix(in srgb, #229ED9 20%, transparent); color: #1c8bc0; }
.ch-chip.ch-max { background: color-mix(in srgb, #ff5c00 20%, transparent); color: #e05300; }
@media (prefers-color-scheme: dark){ .ch-chip.ch-tg { color: #5cc3ef; } .ch-chip.ch-max { color: #ff8a4d; } }
:root[data-theme="dark"] .ch-chip.ch-tg { color: #5cc3ef; }
:root[data-theme="dark"] .ch-chip.ch-max { color: #ff8a4d; }
:root[data-theme="light"] .ch-chip.ch-tg { color: #1c8bc0; }
:root[data-theme="light"] .ch-chip.ch-max { color: #e05300; }
.li-preview { font-size: 13px; color: var(--text-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-row2 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.badge { background: var(--danger); color: #fff; font-size: 11px; min-width: 20px; height: 20px;
  border-radius: 10px; padding: 0 6px; display: flex; align-items: center; justify-content: center; align-self: center; flex: 0 0 auto; }

.chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .3px; }
.chip.new { background: #ffe9c7; color: #9a6300; }
.chip.open { background: #cfe8ff; color: #0b5bb5; }
.chip.in_progress { background: #e0d4ff; color: #5b30b5; }
.chip.closed { background: #d6f0d8; color: #1f7a2b; }
html[data-theme="dark"] .chip.new { background:#4a3a16; color:#f3c468;}
html[data-theme="dark"] .chip.open { background:#16344f; color:#7fc0ff;}
html[data-theme="dark"] .chip.in_progress { background:#2f2350; color:#bda6ff;}
html[data-theme="dark"] .chip.closed { background:#1d3a22; color:#7fdc8c;}

.filters { display: flex; gap: 6px; padding: 10px 12px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.filter-tab { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); padding: 6px 12px; border-radius: 20px; white-space: nowrap; font-size: 13px; }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Чат — Telegram-эстетика: обои, стекло, хвостики, физика */
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
/* Обои — ТОЛЬКО в окне переписки (.conversation), НЕ в списках разделов */
.chat-wrap.conversation { background: var(--chat-bg); }
.chat-wrap.conversation::before { content:""; position:absolute; inset:0; z-index:0; pointer-events:none;
  background-image: var(--chat-doodle); background-size: 150px 150px; opacity:.28; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 5px;
  background: transparent; position: relative; z-index: 1; scroll-behavior: smooth; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; }
.msg { position: relative; max-width: min(82%, 560px); min-width: 0; padding: 7px 11px 6px; border-radius: 16px;
  overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; font-size: 14.5px; line-height: 1.38;
  box-shadow: 0 1px 1.5px rgba(16,24,40,.14); transform-origin: bottom; will-change: transform; }
.msg.enter { animation: msg-pop .28s cubic-bezier(.2,.8,.3,1) both; }
.msg.in { align-self: flex-start; background: var(--bubble-in); color: var(--text); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--bubble-out-grad); color: #fff; border-bottom-right-radius: 5px; }
/* Хвостики у последнего пузыря группы (как в Telegram) */
.msg.glast.in::after { content:""; position:absolute; left:-6px; bottom:0; width:14px; height:16px;
  background: var(--bubble-in); border-bottom-right-radius: 14px; clip-path: path("M14 16 L14 0 Q14 12 0 16 Z"); }
.msg.glast.out::after { content:""; position:absolute; right:-6px; bottom:0; width:14px; height:16px;
  background: var(--bubble-out-tail); border-bottom-left-radius: 14px; clip-path: path("M0 16 L0 0 Q0 12 14 16 Z"); }
.msg-author { font-size: 12.5px; font-weight: 700; color: var(--author-color); margin-bottom: 2px; }
.msg.out .msg-author { color: rgba(255,255,255,.92); }
.msg-meta { font-size: 10.5px; color: var(--text-dim); text-align: right; margin-top: 2px; user-select: none; white-space: nowrap; }
.msg.out .msg-meta { color: rgba(255,255,255,.82); }
/* Время В СТРОКЕ с текстом (как в Telegram): реальное .msg-meta абсолютно справа-снизу,
   а невидимый «призрак» той же ширины в конце текста резервирует место, чтобы
   последняя строка не залезала под время. */
.msg.has-inline-meta { padding-bottom: 6px; }
.msg.has-inline-meta .msg-body { display: inline; }
.msg.has-inline-meta .msg-meta { position: absolute; right: 11px; bottom: 5px; margin: 0; }
.meta-ghost { display: inline-block; visibility: hidden; margin-left: 8px; font-size: 10.5px; user-select: none; }
.meta-ghost .tick { letter-spacing: -1px; }
.msg.out .tick { color: rgba(255,255,255,.9); }
.msg.out .tick.read { color: #d5f5ff; }
.msg-fwd { font-size: 12px; color: var(--text-dim); border-left: 2px solid var(--primary); padding-left: 6px; margin-bottom: 4px; }
/* Композер и превью ответа — матовое стекло поверх обоев */
.reply-bar { flex: 0 0 auto; display: flex; gap: 7px; padding: 7px 8px; padding-bottom: calc(7px + var(--safe-bottom));
  background: var(--glass-bg); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-top: 1px solid var(--glass-border); align-items: flex-end; position: relative; z-index: 2; }
.reply-bar textarea { flex: 1; resize: none; border: 1px solid var(--glass-border); border-radius: 20px; padding: 9px 14px; max-height: 120px;
  background: var(--input-bg); color: var(--text); transition: border-color .15s; }
.reply-bar textarea:focus { outline: none; border-color: var(--primary); }
.reply-bar button[type="submit"] { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--accent-grad); color: #fff; font-size: 18px; box-shadow: 0 3px 10px rgba(37,99,235,.35);
  transition: transform .15s cubic-bezier(.22,1.4,.36,1); }
.reply-bar button[type="submit"]:active { transform: scale(.86); }
.reply-bar button:disabled { opacity: .5; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-tile { background: var(--surface); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.kpi-val { font-size: 26px; font-weight: 700; }
.kpi-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.kpi-tile.full { grid-column: 1 / -1; }
.kpi-modes { display:flex; gap:8px; margin-bottom:12px; }
.kpi-modes .filter-tab { flex:1; text-align:center; padding:9px 12px; }
.kpi-controls { display:flex; align-items:center; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.kpi-period-label { font-weight:700; flex:1; text-align:center; min-width:130px; font-size:16px; }
.kpi-controls input[type="date"] { padding:9px 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); }
.section-h { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; margin: 16px 2px 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.bar-row .bar-label { width: 38%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.bar-row .bar-num { width: 36px; text-align: right; color: var(--text-dim); }

/* Профиль / Настройки */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; font-weight: 600; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.btn { padding: 12px 16px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 600; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .6; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.row-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.row-setting .rs-label { font-weight: 500; }
.row-setting .rs-sub { font-size: 12px; color: var(--text-dim); }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px; }
.profile-photo .pp-img { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; color: var(--text-dim); }
.contact-row { display: flex; gap: 8px; margin-bottom: 8px; }
.contact-row select { flex: 0 0 40%; }
.contact-row input { flex: 1; }
.contact-row button { flex: 0 0 auto; }

.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 14px; transition: .2s; }
.switch .track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(20px); }

.fab { position: absolute; right: 16px; bottom: calc(16px + var(--safe-bottom)); width: 54px; height: 54px;
  border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 26px; box-shadow: 0 3px 10px rgba(0,0,0,.3); z-index: 10; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 18px; border-radius: 22px; z-index: 100; font-size: 14px; box-shadow: 0 3px 12px rgba(0,0,0,.4); max-width: 90vw; }

/* Внутренний баннер уведомления (кликабельный) */
.notif-banner { position: fixed; top: calc(var(--safe-top) + 8px); left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  padding: 11px 16px; border-radius: 12px; z-index: 110; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.28); max-width: 92vw; display: flex; align-items: center; gap: 8px;
  animation: nb-in .22s ease; cursor: pointer; }
@keyframes nb-in { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Слайдер громкости */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; background: var(--border); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--primary); cursor: pointer; }
.row-setting select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); }

/* Десктоп: drawer постоянно слева, контент со сдвигом */
@media (min-width: 900px) {
  #menu-btn { display: none; }
  .scrim { display: none !important; }
  .drawer { transform: translateX(0); box-shadow: none; border-right: 1px solid var(--border); }
  #app-screen { padding-left: 280px; }
}

/* ═══════════════ Дизайн-полировка ═══════════════ */
/* Акцентные градиенты на ключевых элементах */
.topbar { background: var(--accent-grad); box-shadow: 0 2px 10px rgba(37,99,235,.25); }
.login-logo { background: var(--accent-grad); box-shadow: 0 8px 20px rgba(37,99,235,.35); }
.drawer-head { background: var(--accent-grad); }
.avatar { background: var(--accent-grad); color:#fff; box-shadow: 0 3px 8px rgba(37,99,235,.3); }
.login-card button, .btn:not(.secondary):not(.danger), .reply-bar button, .fab {
  background: var(--accent-grad);
  box-shadow: 0 4px 12px rgba(37,99,235,.28);
}
.btn:not(.secondary):not(.danger):active { filter: brightness(.95); }

/* Фон логина — мягкий градиент */
#login-screen {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79,70,229,.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(37,99,235,.16), transparent 55%),
    var(--bg);
}
.login-card { border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }

/* Карточки и списки — мягче и воздушнее */
.card { border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-pad { padding: 16px; }
.list-item { transition: background .12s ease; }
.list-item:first-child { border-top-left-radius: 0; }
.pane-pad { padding: 14px; }

/* Активный пункт меню — с акцентной полоской */
.nav-item { transition: background .12s ease; }
.nav-item.active { background: color-mix(in srgb, var(--primary) 12%, transparent); position: relative; }
.nav-item.active::before {
  content:""; position:absolute; left:0; top:8px; bottom:8px; width:3px;
  border-radius:0 3px 3px 0; background: var(--accent-grad);
}

/* Утилиты для раздела «Пользователи» и форм */
.form-grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.avatar-sm { width:42px; height:42px; font-size:15px; background: var(--surface-2); color: var(--text-dim); }
.avatar.has-photo { background-size: cover !important; background-position: center; background-color: var(--surface-2); box-shadow: var(--shadow); }
.btn-sm { padding:8px 14px; border-radius:10px; font-size:13px; align-self:center; flex:0 0 auto; }
.muted { color: var(--text-dim); font-weight:400; font-size:12px; }
.li-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.input-row { display:flex; gap:8px; align-items:center; }
.input-row input { flex:1; }
.li-link { display:flex; align-items:center; gap:8px; margin-top:8px; flex-wrap:wrap; }
.link-select { padding:7px 10px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); color:var(--text); max-width:100%; }

/* ── Спецчат: богатые сообщения ── */
.msg-author { font-size:12px; font-weight:600; color:var(--primary); margin-bottom:2px; }
.msg-body { white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; }
.msg-reply { border-left:3px solid var(--primary); padding:3px 8px; margin-bottom:5px; font-size:12px; background:rgba(0,0,0,.05); border-radius:6px; line-height:1.25; }
.msg-reply b { display:block; color:var(--primary); }
.msg.out .msg-reply { background:rgba(255,255,255,.18); border-left-color:rgba(255,255,255,.7); }
.msg.out .msg-reply b { color:#fff; }
.msg-img { max-width:230px; max-height:280px; border-radius:10px; display:block; cursor:pointer; margin:2px 0; }
/* Пока медиа не загрузилось (src ставится async из blob-кэша) — резервируем место,
   иначе при перерисовке списка фото схлопываются в 0px и скролл «уезжает» вверх. */
.msg-img:not(.ld) { min-height:120px; min-width:150px; background:rgba(128,128,128,.14); }
.msg-audio { width:230px; max-width:60vw; height:38px; margin:3px 0; }
.msg-file { background:var(--surface-2); border:1px solid var(--border); color:var(--text); border-radius:9px; padding:7px 11px; cursor:pointer; font-size:13px; }
.msg.out .msg-file { background:rgba(255,255,255,.2); color:#fff; border-color:rgba(255,255,255,.3); }
.tick { font-size:11px; opacity:.85; margin-left:3px; }
.tick.read { color:#7fd7ff; }
/* Карточка обращения/тикета — выделяется от обычных сообщений */
.msg-ticket { align-self:stretch; max-width:92%; background:var(--surface);
  border:1px solid var(--warn); border-left:4px solid var(--warn); border-radius:14px;
  padding:11px 13px; box-shadow:0 3px 12px rgba(232,146,12,.18); margin:6px auto 6px 0; }
.msg-ticket .mt-badge { display:inline-block; background:var(--warn); color:#fff; font-size:11px; font-weight:700; padding:3px 10px; border-radius:12px; letter-spacing:.3px; }
.msg-ticket .mt-obj { font-weight:700; font-size:15px; margin-top:8px; }
.msg-ticket .mt-author { font-size:13px; color:var(--text-dim); margin-top:3px; }
.msg-ticket .mt-text { margin-top:7px; white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; }
.msg-ticket .mt-meta { font-size:11px; color:var(--text-dim); margin-top:8px; }
/* Поле ввода: вложение + превью ответа */
.attach-btn { flex:0 0 auto; width:42px; height:42px; border-radius:50%; border:none; background:var(--surface-2); color:var(--text); font-size:18px; }
.attach-btn:active { background:var(--border); }
.attach-btn:disabled { opacity:.55; }
.attach-btn.rec { background:#e5484d; color:#fff; animation:mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100%{ box-shadow:0 0 0 0 rgba(229,72,77,.5); } 50%{ box-shadow:0 0 0 6px rgba(229,72,77,0); } }
/* Сворачиваемая панель инструментов композера (📎😊🎤✨ под кнопкой ＋) */
.tools-toggle { font-size:24px; line-height:1; transition:transform .2s cubic-bezier(.22,1.4,.36,1), background .15s; }
.tools-toggle.open { transform:rotate(135deg); background:var(--accent-grad); color:#fff; }
.tools-tray { position:absolute; left:8px; bottom:calc(100% + 8px); z-index:6; display:flex; gap:8px; padding:8px;
  border-radius:18px; background:var(--glass-bg); backdrop-filter:blur(20px) saturate(1.5); -webkit-backdrop-filter:blur(20px) saturate(1.5);
  border:1px solid var(--glass-border); box-shadow:0 8px 28px rgba(0,0,0,.28);
  transform:translateY(10px) scale(.94); transform-origin:bottom left; opacity:0; pointer-events:none;
  transition:transform .18s cubic-bezier(.22,1.4,.36,1), opacity .15s; }
.tools-tray.open { transform:none; opacity:1; pointer-events:auto; }
.tools-tray .attach-btn { animation:tool-pop .22s cubic-bezier(.22,1.4,.36,1) both; }
.tools-tray.open .attach-btn:nth-child(1){ animation-delay:0ms; } .tools-tray.open .attach-btn:nth-child(2){ animation-delay:35ms; }
.tools-tray.open .attach-btn:nth-child(3){ animation-delay:70ms; } .tools-tray.open .attach-btn:nth-child(4){ animation-delay:105ms; }
@keyframes tool-pop { 0%{ transform:scale(.5); opacity:0; } 100%{ transform:scale(1); opacity:1; } }
@media (prefers-reduced-motion:reduce){ .tools-tray,.tools-toggle,.tools-tray .attach-btn{ transition:none; animation:none; } }
.reply-preview { display:flex; align-items:center; gap:8px; padding:8px 12px; background:var(--surface-2); border-top:1px solid var(--border); }
.reply-preview .rp-body { flex:1; font-size:13px; border-left:3px solid var(--primary); padding-left:8px; min-width:0; overflow:hidden; }
.reply-preview .rp-body b { color:var(--primary); }
.reply-preview .rp-x { border:none; background:transparent; font-size:16px; color:var(--text-dim); cursor:pointer; }
/* Нижнее меню действий */
.sheet-scrim { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:120; display:flex; align-items:flex-end; }
.sheet { background:var(--surface); width:100%; border-radius:18px 18px 0 0; padding:8px; padding-bottom:calc(8px + var(--safe-bottom)); box-shadow:var(--shadow-lg); animation:nb-in .2s ease; }
.sheet-btn { display:block; width:100%; text-align:center; padding:15px; border:none; background:transparent; color:var(--text); font-size:16px; border-radius:12px; }
.sheet-btn:active { background:var(--surface-2); }
.sheet-btn.danger { color:var(--danger); }
.sheet-btn.cancel { margin-top:6px; font-weight:700; background:var(--surface-2); }
/* Модальный диалог (замена нативных prompt/confirm, не работающих в PWA) */
.dlg-scrim { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:140; display:flex; align-items:center; justify-content:center; padding:24px; }
.dlg { background:var(--surface); width:100%; max-width:360px; border-radius:16px; padding:18px; box-shadow:var(--shadow-lg); animation:nb-in .18s ease; }
.dlg-msg { font-size:15px; color:var(--text); margin-bottom:14px; white-space:pre-wrap; }
.dlg-input { width:100%; box-sizing:border-box; padding:11px 12px; font-size:16px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); margin-bottom:14px; resize:vertical; }
.dlg-input:focus { outline:none; border-color:var(--accent); }
.dlg-row { display:flex; gap:8px; }
.dlg-col { display:flex; flex-direction:column; gap:8px; }
.dlg-col .dlg-btn { width:100%; }
.dlg-btn { flex:1; }
/* Просмотр фото */
.lightbox { position:fixed; inset:0; background:rgba(0,0,0,.92); z-index:130; display:flex; align-items:center; justify-content:center; overflow:hidden; touch-action:none; -webkit-user-select:none; user-select:none; }
.lightbox img { max-width:96vw; max-height:92vh; border-radius:8px; box-shadow:0 8px 40px rgba(0,0,0,.6);
  transform-origin:center center; will-change:transform; touch-action:none; -webkit-user-drag:none; cursor:zoom-in; }
.lightbox.zoomed img { cursor:grab; }
.lb-close { position:absolute; top:calc(12px + var(--safe-top)); right:16px; width:44px; height:44px; border-radius:50%; border:none; background:rgba(255,255,255,.16); color:#fff; font-size:20px; z-index:131; }
/* Голосовые */
.msg-voice { display:flex; flex-direction:column; gap:4px; }
.mv-row { display:flex; align-items:center; gap:8px; }
.mv-ic { font-size:18px; }
.mv-tr { font-size:13px; color:var(--text-dim); font-style:italic; }
.msg.out .mv-tr { color:rgba(255,255,255,.88); }
/* Чек-лист участников группы */
.check-row { display:flex; align-items:center; gap:10px; padding:11px 12px; border-bottom:1px solid var(--border); cursor:pointer; }
.check-row input { width:18px; height:18px; flex:0 0 auto; }
.btn-col { display:flex; flex-direction:column; gap:8px; margin-top:14px; }
.btn-col .btn { width:100%; }
/* Группировка сообщений (Telegram/WhatsApp-стиль) */
.day-sep { text-align:center; margin:12px 0 8px; }
.day-sep span { background:var(--surface-2); color:var(--text-dim); font-size:12px; padding:4px 12px; border-radius:12px; box-shadow:var(--shadow); }
.msg-row { display:flex; align-items:flex-end; gap:8px; align-self:flex-start; max-width:88%; }
.msg-row .msg { align-self:auto; max-width:100%; }
.msg-row.grouped { margin-top:-3px; }
.row-av { width:30px; height:30px; flex:0 0 auto; border-radius:50%; }
.row-av.avatar { font-size:11px; }
.msg.in:not(.glast) { border-bottom-left-radius:14px; }
.msg.glast.in { border-bottom-left-radius:4px; }
.msg.out:not(.glast) { border-bottom-right-radius:14px; margin-bottom:-3px; }
.msg.glast.out { border-bottom-right-radius:4px; }
/* ─── Telegram-подобные улучшения чата ─── */
.msg-link { color:inherit; text-decoration:underline; text-underline-offset:2px; word-break:break-all; }
.msg.in .msg-link { color:var(--primary); }
.msg-reply { cursor:pointer; }
.msg.flash { animation:msg-flash 1.6s ease; }
@keyframes msg-flash { 0%,100%{ box-shadow:0 1px 2px rgba(0,0,0,.07); } 15%,55%{ box-shadow:0 0 0 3px var(--primary); } }
.msg[data-mid]{ touch-action:pan-y; }
/* Разделитель непрочитанных */
.unread-sep { text-align:center; margin:10px 0 6px; }
.unread-sep span { display:inline-block; background:var(--primary); color:#fff; font-size:11px; font-weight:700; padding:3px 14px; border-radius:12px; opacity:.92; }
/* Кнопка «вниз» + счётчик новых */
.scroll-fab { position:absolute; right:14px; bottom:80px; width:44px; height:44px; border-radius:50%; border:none;
  background:var(--surface); color:var(--text); font-size:22px; line-height:1; box-shadow:var(--shadow-lg); z-index:15; cursor:pointer; }
.chat-wrap { position:relative; }
.sf-badge { position:absolute; top:-6px; right:-4px; min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:var(--primary); color:#fff; font-size:11px; font-weight:700; line-height:18px; text-align:center; }
/* Эмодзи-палитра */
.emoji-panel { display:flex; flex-wrap:wrap; gap:2px; padding:8px; background:var(--surface-2); border-top:1px solid var(--border); max-height:150px; overflow-y:auto; }
.emoji-cell { border:none; background:transparent; font-size:22px; padding:5px 7px; border-radius:8px; cursor:pointer; }
.emoji-cell:active { background:var(--border); }
/* Панель гифок (Tenor) */
.gif-panel { display:flex; flex-direction:column; background:var(--surface-2); border-top:1px solid var(--border); max-height:300px; animation:fab-in .18s ease both; }
.gif-search { display:flex; gap:6px; padding:8px; align-items:center; }
.gif-search input { flex:1; border:1px solid var(--glass-border); border-radius:16px; padding:8px 12px; background:var(--surface); color:var(--text); font-size:14px; }
.gif-search input:focus { outline:none; border-color:var(--primary); }
.gif-search .gif-x { flex:0 0 auto; width:32px; height:32px; border:none; background:transparent; color:var(--text-dim); font-size:16px; cursor:pointer; border-radius:50%; }
.gif-search .gif-x:active { background:var(--border); }
.gif-grid { display:grid; grid-template-columns:repeat(3,1fr); grid-auto-rows:96px; gap:4px; padding:0 8px 8px; overflow-y:auto; align-content:start; }
.gif-cell { border:none; padding:0; margin:0; background:var(--border); border-radius:8px; overflow:hidden; cursor:pointer; position:relative; width:100%; height:96px; }
.gif-cell img { width:100%; height:100%; object-fit:cover; display:block; }
.gif-cell:active { transform:scale(.94); }
.gif-cell.sending { opacity:.5; pointer-events:none; }
.gif-cell.sending::after { content:"⏳"; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:20px; background:rgba(0,0,0,.3); }
.gif-empty { grid-column:1/-1; text-align:center; color:var(--text-dim); font-size:13px; padding:24px 8px; }
@media (prefers-color-scheme: dark){ .gif-panel { background:var(--glass-bg); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); } }
@media (prefers-reduced-motion: reduce){ .gif-panel { animation:none; } .gif-cell:active { transform:none; } }
/* Реакции */
.msg-reacts { display:flex; flex-wrap:wrap; gap:4px; margin-top:5px; }
.msg-react-chip { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:12px; padding:1px 8px; font-size:12px; cursor:pointer; display:inline-flex; gap:3px; align-items:center; }
.msg-react-chip.mine { border-color:var(--primary); background:color-mix(in srgb, var(--primary) 16%, transparent); }
.msg.out .msg-react-chip { background:rgba(255,255,255,.22); border-color:rgba(255,255,255,.35); color:#fff; }
.sheet-reacts { display:flex; justify-content:space-around; padding:8px 6px 12px; border-bottom:1px solid var(--border); margin-bottom:6px; }
.sheet-react { border:none; background:transparent; font-size:26px; padding:6px 8px; border-radius:50%; cursor:pointer; transition:transform .12s cubic-bezier(.22,1.4,.36,1); }
.sheet-react:hover { transform:scale(1.25); }
.sheet-react:active { transform:scale(.85); background:var(--surface-2); }
/* ─── Физика и динамика ─── */
@keyframes msg-pop { from{ opacity:0; transform:translateY(10px) scale(.96); } to{ opacity:1; transform:none; } }
/* Реакции: pop при появлении */
.msg-react-chip { animation:react-pop .28s cubic-bezier(.22,1.5,.36,1) both; transition:transform .12s; }
.msg-react-chip:active { transform:scale(.9); }
.msg-react-chip.mine { border-color:var(--primary); background:color-mix(in srgb, var(--primary) 18%, transparent); font-weight:600; }
@keyframes react-pop { 0%{ transform:scale(0); } 70%{ transform:scale(1.15); } 100%{ transform:scale(1); } }
/* Стеклянная кнопка «вниз» */
.scroll-fab { background:var(--glass-bg); backdrop-filter:blur(14px) saturate(1.4); -webkit-backdrop-filter:blur(14px) saturate(1.4);
  border:1px solid var(--glass-border); color:var(--text); box-shadow:0 4px 16px rgba(0,0,0,.18);
  animation:fab-in .2s cubic-bezier(.22,1.3,.36,1) both; transition:transform .12s; }
.scroll-fab:active { transform:scale(.9); }
@keyframes fab-in { from{ opacity:0; transform:translateY(12px) scale(.8); } to{ opacity:1; transform:none; } }
/* Плавающая дата при прокрутке (sticky, как в Telegram) */
.day-sep { position:sticky; top:4px; z-index:5; transition:opacity .25s; }
.day-sep span { backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px); background:var(--glass-bg); }
.messages.scrolling-idle .day-sep:not(:last-of-type) { opacity:0; }
/* Стрелка ответа при свайпе */
.msg .swipe-arrow { position:absolute; left:-34px; top:50%; transform:translateY(-50%) scale(.4); opacity:0;
  width:26px; height:26px; border-radius:50%; background:var(--primary); color:#fff; display:grid; place-items:center;
  font-size:14px; transition:transform .1s, opacity .1s; pointer-events:none; }
/* Разделитель непрочитанных — стеклянный */
.unread-sep span { background:color-mix(in srgb, var(--primary) 88%, transparent); backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px); box-shadow:0 2px 8px rgba(0,0,0,.15); }
/* Эмодзи-палитра — стекло */
.emoji-panel { background:var(--glass-bg); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); animation:fab-in .18s ease both; }
.emoji-cell { transition:transform .1s; }
.emoji-cell:hover { transform:scale(1.2); }
.reply-preview { background:var(--glass-bg); backdrop-filter:blur(16px) saturate(1.4); -webkit-backdrop-filter:blur(16px) saturate(1.4); animation:rp-in .2s ease both; }
@keyframes rp-in { from{ opacity:0; max-height:0; } to{ opacity:1; max-height:60px; } }
@media (prefers-reduced-motion: reduce){ .msg,.msg-react-chip,.scroll-fab,.emoji-panel,.reply-preview{ animation:none !important; } }
/* ─── Контекст-меню сообщения (как в Telegram) ─── */
.ctx-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.32);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s ease; }
.ctx-overlay.open { opacity: 1; }
.ctx-overlay.closing { opacity: 0; }
.ctx-clone { z-index: 3001 !important; box-shadow: 0 10px 34px rgba(0,0,0,.32); pointer-events: none;
  animation: ctx-clone .22s cubic-bezier(.22,1.3,.36,1) both; }
@keyframes ctx-clone { from { transform: scale(.97); } to { transform: scale(1); } }
.ctx-reacts { position: fixed; z-index: 3002; display: flex; gap: 2px; padding: 5px 7px; border-radius: 26px;
  background: var(--glass-bg); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 6px 22px rgba(0,0,0,.26); border: 1px solid var(--glass-border);
  animation: ctx-pop .24s cubic-bezier(.22,1.5,.36,1) both; }
.ctx-react { border: none; background: transparent; font-size: 25px; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; transition: transform .12s cubic-bezier(.22,1.5,.36,1); }
.ctx-react:hover { transform: scale(1.28); }
.ctx-react:active { transform: scale(.9); }
.ctx-react.active { background: color-mix(in srgb, var(--primary) 24%, transparent); }
.ctx-menu { position: fixed; z-index: 3002; min-width: 210px; max-width: 80vw; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 15px;
  box-shadow: 0 12px 38px rgba(0,0,0,.3); overflow: hidden;
  animation: ctx-pop .2s cubic-bezier(.22,1.35,.36,1) both; }
.ctx-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%;
  padding: 12px 14px; border: none; background: transparent; color: var(--text); font-size: 15.5px;
  border-radius: 11px; text-align: left; transition: background .1s; }
.ctx-row:hover, .ctx-row:active { background: var(--surface-2); }
.ctx-row.danger { color: var(--danger); }
.ctx-label { flex: 1; }
.ctx-ic { font-size: 17px; line-height: 1; opacity: .95; }
@keyframes ctx-pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce){ .ctx-reacts,.ctx-menu,.ctx-clone{ animation: none !important; } }
/* Группировка тикетов по объектам */
.grp-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:12px 14px 6px; font-weight:700; color:var(--text); font-size:14px; background:var(--bg); position:sticky; top:0; z-index:2; }
.grp-cnt { background:var(--surface-2); color:var(--text-dim); border-radius:10px; padding:1px 9px; font-size:12px; font-weight:600; }
.obj-edit { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.obj-edit #tk-obj { flex:1; min-width:120px; font-weight:600; }

/* Статус-чипы вкл/выкл доступа */
.chip.on  { background:#d6f0d8; color:#1f7a2b; }
.chip.off { background:#fde2e4; color:#b42330; }
html[data-theme="dark"] .chip.on  { background:#1d3a22; color:#7fdc8c; }
html[data-theme="dark"] .chip.off { background:#3a1d22; color:#ff8a9a; }

/* Чуть крупнее заголовки разделов, мягкие инпуты */
.section-h { letter-spacing:.6px; }
.form-group input, .form-group textarea, .form-group select,
.login-card input, .row-setting select { border-radius: 11px; transition: border-color .12s ease, box-shadow .12s ease; }
.form-group input:focus, .form-group textarea:focus, .login-card input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
/* Сообщения-пузыри чуть выразительнее */
.msg.out { background: var(--accent-grad); color:#fff; }
.msg.out .msg-meta { color: rgba(255,255,255,.8); }
.msg.out .msg-author { color: rgba(255,255,255,.9); }
