/* Токены по правилам «Дизайн» 1–5: только назначения, одна шкала, обе темы. */
:root, [data-theme="light"] {
  color-scheme: light dark;
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f2f5;
  --color-text: #1b1d21;
  --color-text-secondary: #5c6370;
  --color-border: #d9dde3;
  --color-border-strong: #8a919c;
  --color-accent: #2563c9;
  --color-accent-soft: #e6eefb;
  --color-telegram: #229ed9;
  --color-whatsapp: #1fa855;
  --color-on-accent: #ffffff;
  --color-ok: #1d7a3a;
  --color-ok-soft: #e3f3e8;
  --color-warn: #8a5a00;
  --color-warn-soft: #fbf0d9;
  --color-error: #b42318;
  --color-error-soft: #fbe7e5;
  --color-test: #8a5a00;
  --color-tg: #2b7bb9;
  --color-bubble-in: #ffffff;
  --color-bubble-out: #dcebff;
  --color-note: #fff6d6;
  --color-note-border: #e8cf7a;
  --color-chat-bg: #eef0f3;
  --chat-bg: #e7ebf0;
  --color-header-bg: #ffffff;
  --color-panel-bg: #ffffff;
  --color-composer-bg: transparent;
  --color-input-bg: #ffffff;
  --color-input-border: transparent;
  --input-radius: 22px;
  --color-selected-bg: #2563c9;
  --color-selected-text: #ffffff;
  --color-selected-secondary: #dbe6f7;
  --color-check-read: #2563c9;
  --color-time-out: #5c6370;
  --color-side-company: #2563c9;
  --color-side-client: #1d7a3a;
  --color-side-third: #b45309;
  --color-side-unknown: #6b7280;
  --msg-font: 15px;
  --bubble-radius: 12px;
  --bubble-pad: 6px 10px;
  --group-gap: 8px;
  --color-overlay: rgba(15, 18, 24, .45);
  --shadow: 0 1px 2px rgba(15, 18, 24, .06), 0 4px 16px rgba(15, 18, 24, .06);
  --radius-s: 8px;
  --radius-m: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Тема по умолчанию следует системе; выбранная сотрудником тема задаётся атрибутом data-theme на <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --chat-bg: #0f1114;
    --color-header-bg: #202329;
    --color-panel-bg: #202329;
    --color-composer-bg: #202329;
    --color-input-bg: #2a2e35;
    --color-input-border: transparent;
    --input-radius: 22px;
    --color-selected-bg: #2b4a7a;
    --color-selected-text: #ffffff;
    --color-selected-secondary: #c9d6ea;
    --color-check-read: #7aa7f5;
    --color-time-out: #a3a9b3;
    --color-bg: #17191d;
    --color-surface: #202329;
    --color-surface-hover: #292d34;
    --color-text: #e8eaed;
    --color-text-secondary: #a3a9b3;
    --color-border: #353a42;
    --color-border-strong: #747c88;
    --color-accent: #7aa7f5;
    --color-accent-soft: #263552;
    --color-on-accent: #10151f;
    --color-ok: #6fcf8e;
    --color-ok-soft: #1f3528;
    --color-warn: #f0c060;
    --color-warn-soft: #3a3020;
    --color-error: #f28b82;
    --color-error-soft: #3d2422;
    --color-test: #f0c060;
    --color-tg: #6cb6e8;
    --color-bubble-in: #2a2e35;
    --color-bubble-out: #24395c;
    --color-note: #3a3420;
    --color-note-border: #7a6a35;
    --color-chat-bg: #17191d;
    --color-side-company: #7aa7f5;
    --color-side-client: #6fcf8e;
    --color-side-third: #f0a860;
    --color-side-unknown: #9aa1ab;
    --color-overlay: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
  }
}
[data-theme="dark"] {
  color-scheme: dark;
  --chat-bg: #0f1114;
  --color-header-bg: #202329;
  --color-panel-bg: #202329;
  --color-composer-bg: #202329;
  --color-input-bg: #2a2e35;
  --color-input-border: transparent;
  --input-radius: 22px;
  --color-selected-bg: #2b4a7a;
  --color-selected-text: #ffffff;
  --color-selected-secondary: #c9d6ea;
  --color-check-read: #7aa7f5;
  --color-time-out: #a3a9b3;
  --color-bg: #17191d;
  --color-surface: #202329;
  --color-surface-hover: #292d34;
  --color-text: #e8eaed;
  --color-text-secondary: #a3a9b3;
  --color-border: #353a42;
  --color-border-strong: #747c88;
  --color-accent: #7aa7f5;
  --color-accent-soft: #263552;
  --color-on-accent: #10151f;
  --color-ok: #6fcf8e;
  --color-ok-soft: #1f3528;
  --color-warn: #f0c060;
  --color-warn-soft: #3a3020;
  --color-error: #f28b82;
  --color-error-soft: #3d2422;
  --color-test: #f0c060;
  --color-tg: #6cb6e8;
  --color-bubble-in: #2a2e35;
  --color-bubble-out: #24395c;
  --color-note: #3a3420;
  --color-note-border: #7a6a35;
  --color-chat-bg: #17191d;
  --color-side-company: #7aa7f5;
  --color-side-client: #6fcf8e;
  --color-side-third: #f0a860;
  --color-side-unknown: #9aa1ab;
  --color-overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
}
[data-theme="light"], [data-theme="telegram"], [data-theme="whatsapp"] { color-scheme: light; }
[data-theme="telegram"] {
  /* Палитра в духе Telegram Web: синий акцент, белые панели, зелёный фон чата с узором, круглое поле ввода */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-hover: #f4f4f5;
  --color-border: #dfe1e5;
  --color-text: #000000;
  --color-text-secondary: #707579;
  --color-accent: #3390ec;
  --color-accent-soft: #e8f2fd;
  --color-on-accent: #ffffff;
  --color-tg: #3390ec;
  --color-bubble-in: #ffffff;
  --color-bubble-out: #e3fee0;
  --chat-bg: 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%20fill%3D%22none%22%20stroke%3D%22rgba%2860%2C90%2C30%2C.13%29%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%20%3Cpath%20d%3D%22M14%2022h22a6%206%200%200%201%206%206v10a6%206%200%200%201-6%206H24l-7%206v-6h-3a6%206%200%200%201-6-6V28a6%206%200%200%201%206-6z%22/%3E%20%3Cpath%20d%3D%22M104%2014l3.5%207%207.7%201.1-5.6%205.4%201.3%207.7-6.9-3.6-6.9%203.6%201.3-7.7-5.6-5.4%207.7-1.1z%22/%3E%20%3Cpath%20d%3D%22M70%2078c-4-6-14-4-14%204%200%207%2014%2014%2014%2014s14-7%2014-14c0-8-10-10-14-4z%22/%3E%20%3Ccircle%20cx%3D%22134%22%20cy%3D%2270%22%20r%3D%228%22/%3E%3Ccircle%20cx%3D%22134%22%20cy%3D%2270%22%20r%3D%222.5%22/%3E%20%3Cpath%20d%3D%22M18%20112l30-12-10%2030-6-11z%22/%3E%3Cpath%20d%3D%22M32%20119l16-19%22/%3E%20%3Cpath%20d%3D%22M118%20118v-20l14-4v20%22/%3E%3Ccircle%20cx%3D%22114%22%20cy%3D%22118%22%20r%3D%224%22/%3E%3Ccircle%20cx%3D%22128%22%20cy%3D%22114%22%20r%3D%224%22/%3E%20%3Cpath%20d%3D%22M62%20140h18M71%20131v18%22/%3E%20%3Cpath%20d%3D%22M140%20150a6%206%200%201%200%2012%200a6%206%200%201%200%20-12%200%22/%3E%20%3Cpath%20d%3D%22M84%2030c6%200%206%208%2012%208s6-8%2012-8%22/%3E%20%3C/svg%3E"), linear-gradient(150deg, #dbe8a6 0%, #a9cc8a 45%, #c7dca3 75%, #8fbf86 100%);
  --color-composer-bg: transparent;
  --color-input-bg: #ffffff;
  --color-input-border: transparent;
  --input-radius: 22px;
  --color-selected-bg: #3390ec;
  --color-selected-text: #ffffff;
  --color-selected-secondary: #e6f0fb;
  --color-check-read: #4fae4e;
  --color-time-out: #4fae4e;
  --color-side-company: #3390ec;
  --color-side-client: #3a9a3a;
  --color-side-third: #e17b17;
  --bubble-radius: 15px;
}
[data-theme="whatsapp"] {
  /* Палитра в духе WhatsApp Web: зелёный акцент, серые шапки, бежевый фон чата с узором */
  --color-bg: #eae6df;
  --color-surface: #ffffff;
  --color-surface-hover: #f5f6f6;
  --color-border: #e9edef;
  --color-text: #111b21;
  --color-text-secondary: #667781;
  --color-accent: #00a884;
  --color-accent-soft: #d9fdd3;
  --color-on-accent: #ffffff;
  --color-ok: #008069;
  --color-tg: #008069;
  --color-bubble-in: #ffffff;
  --color-bubble-out: #d9fdd3;
  --chat-bg: 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%20fill%3D%22none%22%20stroke%3D%22rgba%28110%2C95%2C70%2C.11%29%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%20%3Cpath%20d%3D%22M14%2022h22a6%206%200%200%201%206%206v10a6%206%200%200%201-6%206H24l-7%206v-6h-3a6%206%200%200%201-6-6V28a6%206%200%200%201%206-6z%22/%3E%20%3Cpath%20d%3D%22M104%2014l3.5%207%207.7%201.1-5.6%205.4%201.3%207.7-6.9-3.6-6.9%203.6%201.3-7.7-5.6-5.4%207.7-1.1z%22/%3E%20%3Cpath%20d%3D%22M70%2078c-4-6-14-4-14%204%200%207%2014%2014%2014%2014s14-7%2014-14c0-8-10-10-14-4z%22/%3E%20%3Ccircle%20cx%3D%22134%22%20cy%3D%2270%22%20r%3D%228%22/%3E%3Ccircle%20cx%3D%22134%22%20cy%3D%2270%22%20r%3D%222.5%22/%3E%20%3Cpath%20d%3D%22M18%20112l30-12-10%2030-6-11z%22/%3E%3Cpath%20d%3D%22M32%20119l16-19%22/%3E%20%3Cpath%20d%3D%22M118%20118v-20l14-4v20%22/%3E%3Ccircle%20cx%3D%22114%22%20cy%3D%22118%22%20r%3D%224%22/%3E%3Ccircle%20cx%3D%22128%22%20cy%3D%22114%22%20r%3D%224%22/%3E%20%3Cpath%20d%3D%22M62%20140h18M71%20131v18%22/%3E%20%3Cpath%20d%3D%22M140%20150a6%206%200%201%200%2012%200a6%206%200%201%200%20-12%200%22/%3E%20%3Cpath%20d%3D%22M84%2030c6%200%206%208%2012%208s6-8%2012-8%22/%3E%20%3C/svg%3E"), #efeae2;
  --color-header-bg: #f0f2f5;
  --color-composer-bg: #f0f2f5;
  --color-input-bg: #ffffff;
  --color-input-border: transparent;
  --input-radius: 8px;
  --color-selected-bg: #f0f2f5;
  --color-selected-text: #111b21;
  --color-selected-secondary: #667781;
  --color-check-read: #53bdeb;
  --color-time-out: #667781;
  --color-side-company: #1f7aec;
  --color-side-client: #008069;
  --color-side-third: #c76f00;
  --bubble-radius: 8px;
}
:root[data-density="compact"] { --bubble-pad: 4px 8px; --group-gap: 4px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--color-bg); color: var(--color-text); font: 16px/1.5 var(--font); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.secondary { color: var(--color-text-secondary); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


/* Каркас: меню слева, на телефоне — вкладки сверху */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: var(--vh, 100vh); }
/* В переписке страница не прокручивается: высоту задаёт видимая часть окна (--vh из скрипта), клавиатура телефона её уменьшает */
html:has(body.inbox-mode), body.inbox-mode { height: var(--vh, 100dvh); overflow: hidden; }
.inbox-mode .app { min-height: 0; height: var(--vh, 100dvh); }
.nav { background: var(--color-surface); border-right: 1px solid var(--color-border); padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; }
button.brand { width: 100%; border: 0; background: none; color: inherit; font-family: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-s); }
button.brand:hover .brand-mark { filter: brightness(1.1); }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius-s); display: grid; place-items: center;
  background: var(--color-accent); color: var(--color-on-accent); font-size: 14px;
}
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-s);
  color: var(--color-text); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--color-surface-hover); }
.nav a[aria-current="page"] { background: var(--color-accent-soft); color: var(--color-accent); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav-foot { margin-top: 24px; padding: 0 12px; font-size: 12px; }
.nav-foot a { min-height: 32px; padding: 0; font-weight: 400; color: var(--color-text-secondary); }

.main { padding: 24px; min-width: 0; }
/* Колонка справа от меню: закреплённое предупреждение сверху, страница под ним */
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main-col > .main { flex: 1 1 auto; }
.inbox-mode .main-col { height: var(--vh, 100dvh); }
.alerts { display: grid; gap: 1px; background: #8f1c13; color: #fff; flex: none; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 14px; background: #b42318; }
.alert-text { flex: 1; min-width: 0; }
.alert-btn { background: #fff; color: #b42318; border: 0; flex: none; }
.alert-more { font-size: 13px; padding-top: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; }
.head p { margin: 4px 0 0; font-size: 14px; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-m); box-shadow: var(--shadow); }

/* Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-s); border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 600;
  white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-ghost:hover { background: var(--color-surface-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.field {
  min-height: 40px; padding: 0 12px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-s);
  background: var(--color-surface); font-size: 14px; min-width: 0;
}
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 4px; }

/* Метки */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; min-height: 24px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--color-ok-soft); color: var(--color-ok); }
.badge-warn { background: var(--color-warn-soft); color: var(--color-warn); }
.badge-error { background: var(--color-error-soft); color: var(--color-error); }
.badge-muted { background: var(--color-surface-hover); color: var(--color-text-secondary); }
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.tg { color: var(--color-tg); font-weight: 700; font-size: 12px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative; overflow: hidden;
  font-size: 14px; font-weight: 600; color: #fff;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Сотрудники */
.emp-list { display: grid; gap: 12px; }
.emp { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px; }
.emp-name { font-weight: 600; }
.emp-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; font-size: 14px; }
.emp-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Чаты */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; border-bottom: 1px solid var(--color-border); }
.toolbar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1 1 240px; min-width: 0; }
.search .field { width: 100%; padding-left: 36px; }
.search svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; color: var(--color-text-secondary); }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius-s); background: var(--color-surface-hover); }
.seg button {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--color-text-secondary); font-weight: 500; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow); }
.seg .count { font-size: 12px; margin-left: 4px; color: var(--color-text-secondary); }
.addlink { display: flex; gap: 8px; flex: 1 1 320px; min-width: 0; }
.addlink .field { flex: 1; width: 0; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  min-height: 64px; padding: 12px 16px; border-bottom: 1px solid var(--color-border);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--color-surface-hover); }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--color-text-secondary); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.row-main { min-width: 0; }
.row-time { font-size: 12px; color: var(--color-text-secondary); }

/* Переключатель */
.switch {
  position: relative; width: 44px; height: 24px; border-radius: 999px; border: 0; cursor: pointer; flex: none;
  background: var(--color-border-strong); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--color-accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: progress; }
.switch-wrap { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }

/* Состояния */
.skel { padding: 16px; display: grid; gap: 16px; }
.skel div { height: 40px; border-radius: var(--radius-s); background: var(--color-surface-hover); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.empty { padding: 48px 16px; text-align: center; }
.empty h2 { font-size: 16px; margin: 0 0 4px; }
.empty p { margin: 0 0 16px; font-size: 14px; color: var(--color-text-secondary); }
.alert { padding: 12px 16px; border-radius: var(--radius-s); font-size: 14px; background: var(--color-error-soft); color: var(--color-error); }

/* Окна */
dialog {
  border: 0; border-radius: var(--radius-m); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow);
}
dialog::backdrop { background: var(--color-overlay); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 0 24px; }
.dlg-head h2 { font-size: 20px; margin: 0; }
.dlg-body { padding: 16px 24px 24px; display: grid; gap: 16px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: var(--radius-s); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--color-text-secondary);
}
.icon-btn:hover { background: var(--color-surface-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.qr { display: grid; place-items: center; min-height: 280px; }
.qr svg { width: 264px; height: 264px; background: #fff; padding: 8px; border-radius: var(--radius-s); }
.steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--color-text-secondary); }
.steps b { color: var(--color-text); font-weight: 600; }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.roles.hours-mode { display: flex; flex-wrap: wrap; }
.roles.hours-mode label { flex: 0 1 auto; padding-left: 16px; padding-right: 16px; }
/* Профиль: на широком экране две колонки карточек, без растянутых на весь экран полос */
.pcols { display: grid; gap: 12px; align-items: start; max-width: 1200px; }
.pcol { display: grid; gap: 12px; min-width: 0; }
.pcol > .card { margin-top: 0 !important; }
@media (min-width: 1100px) { .pcols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.roles label {
  display: grid; place-items: center; min-height: 44px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-s);
  font-size: 14px; cursor: pointer; text-align: center;
}
.roles input { position: absolute; opacity: 0; }
.roles input:checked + span { color: var(--color-accent); font-weight: 600; }
.roles label:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.roles label:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--radius-s); background: var(--color-text); color: var(--color-bg);
  font-size: 14px; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* Вход */
/* dvh — видимая высота окна: 100vh на телефоне включает место под панелями браузера и сдвигает блок вниз */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .brand { justify-content: center; }
.login h1, .login .hint { text-align: center; }
.login .card { width: min(400px, 100%); padding: 32px 24px; display: grid; gap: 16px; }
.login h1 { font-size: 20px; }
.login .field, .login .btn { width: 100%; min-height: 44px; }

/* Переписка в духе Telegram: три колонки, компактные строки, пузыри с хвостиком, круглые кнопки */
@media (min-width: 761px) {
  .nav-mini .app { grid-template-columns: 64px 1fr; }
  .nav-mini .nav { padding: 12px 8px; }
  .nav-mini .brand { padding: 0 0 12px; justify-content: center; }
  .nav-mini .brand span:not(.brand-mark), .nav-mini .nav-foot { display: none; }
  /* Свёрнутое меню: при наведении рядом со значком подписан пункт */
  .nav-mini .nav a { position: relative; }
  .nav-mini .nav a:hover::after, .nav-mini .nav a:focus-visible::after {
    content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    padding: 6px 10px; border-radius: var(--radius-s); background: var(--color-text); color: var(--color-surface);
    font-size: 13px; font-weight: 500; white-space: nowrap; pointer-events: none; z-index: 50; box-shadow: var(--shadow);
  }
  .nav-mini .nav a { justify-content: center; padding: 0; font-size: 0; gap: 0; border-radius: 12px; }
}
.main.flush { padding: 0; min-height: 0; overflow: hidden; display: grid; }
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; }
/* «Информация о чате» открывается по кнопке и не занимает место, пока не нужна */
.inbox .card-col { display: none !important; }
.inbox.card-open .card-col { display: flex !important; }
.inbox.card-open { grid-template-columns: 360px minmax(0, 1fr) 340px; }
.inbox > section { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--color-border); background: var(--color-panel-bg); }
.inbox > section:last-child { border-right: 0; }
.col-head { padding: 8px 12px; display: grid; gap: 8px; background: var(--color-header-bg); }
.col-head h1 { font-size: 20px; }
.col-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.list .field[type="search"] { border-radius: 22px; border-color: transparent; background: var(--color-surface-hover); min-height: 40px; padding: 0 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--color-surface-hover);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--color-text-secondary);
}
.chip[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); }

/* Строка чата: аватар 48, имя, время, последнее сообщение, таймер ожидания кружком */
.citem {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; width: calc(100% - 16px);
  margin: 0 8px; height: 66px; padding: 0 10px; border: 0; border-radius: 12px; background: transparent;
  text-align: left; cursor: pointer; text-decoration: none; color: inherit;
}
.citem:hover { background: var(--color-surface-hover); }
.citem[aria-current="true"] { background: var(--color-selected-bg); color: var(--color-selected-text); }
.citem[aria-current="true"] .citem-last, .citem[aria-current="true"] .citem-time, .citem[aria-current="true"] .tg { color: var(--color-selected-secondary); }
.citem .avatar { grid-row: 1 / 3; width: 48px; height: 48px; font-size: 16px; }
.citem-title { display: flex; gap: 6px; align-items: center; min-width: 0; font-weight: 600; font-size: 15px; line-height: 20px; }
.citem-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem-time { font-size: 12px; color: var(--color-text-secondary); justify-self: end; }
.citem-last { font-size: 14px; line-height: 20px; color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait { justify-self: end; font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; }
.wait.badge-n { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; display: grid; place-items: center; font-weight: 600; color: #fff; background: var(--color-text-secondary); }
.wait.badge-n.warn { background: #e2a400; }
.wait.badge-n.over { background: var(--color-error); }
.citem .badges { justify-self: end; display: flex; gap: 4px; align-items: center; }
.unread.badge-n { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--color-on-accent); background: var(--color-accent); }
.citem[aria-current="true"] .unread.badge-n { background: var(--color-on-accent); color: var(--color-accent); }
.citem .tg { font-size: 11px; }

/* Шапка чата */
.chat { background: var(--chat-bg) !important; background-size: 200px auto, cover !important; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 12px; height: 56px; flex: none; background: var(--color-header-bg); border-bottom: 1px solid var(--color-border); }
.chat-head .avatar { width: 40px; height: 40px; font-size: 14px; }
.chat-head .t { min-width: 0; flex: 1; line-height: 18px; }
.chat-head .t b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .t small { display: block; font-size: 13px; color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { min-height: 32px; border-radius: 16px; border: 1px solid var(--color-border); background: var(--color-surface-hover); padding: 0 10px; font-size: 13px; max-width: 190px; }
.round {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--color-text-secondary);
}
.round:hover { background: var(--color-surface-hover); }
.round svg { width: 22px; height: 22px; }
.back { display: none; }

/* Лента */
.feed { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 12px 12px; display: flex; flex-direction: column; }
.feed > * { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
.day { width: auto !important; align-self: center; margin: 10px auto 6px !important; padding: 2px 10px; border-radius: 12px; font-size: 13px; font-weight: 500; background: rgba(0, 0, 0, .22); color: #fff; }
.mgroup { display: flex; gap: 8px; align-items: flex-end; margin-top: var(--group-gap); }
.mgroup.out { flex-direction: row-reverse; }
.mgroup > .avatar { width: 34px; height: 34px; font-size: 13px; position: sticky; bottom: 0; flex: none; }
.mgroup.out > .avatar, .mgroup.private > .avatar { display: none; }
.mstack { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: min(520px, 82%); }
.mgroup.in .mstack { align-items: flex-start; }
.mgroup.out .mstack { align-items: flex-end; }
.msg { position: relative; max-width: 100%; }
.bubble {
  position: relative; padding: var(--bubble-pad); border-radius: var(--bubble-radius); background: var(--color-bubble-in);
  font-size: var(--msg-font); line-height: 1.35; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); overflow-wrap: anywhere; white-space: pre-wrap;
  min-width: 60px;
}
.msg.out .bubble { background: var(--color-bubble-out); }
/* Хвостик у последнего пузыря блока */
.mstack > .msg:last-child .bubble::after {
  content: ""; position: absolute; bottom: 0; width: 10px; height: 14px; background: inherit;
}
.mgroup.in .mstack > .msg:last-child .bubble { border-bottom-left-radius: 0; }
.mgroup.in .mstack > .msg:last-child .bubble::after { left: -9px; clip-path: path("M10 0 C10 8 6 12 0 14 L10 14 Z"); }
.mgroup.out .mstack > .msg:last-child .bubble { border-bottom-right-radius: 0; }
.mgroup.out .mstack > .msg:last-child .bubble::after { right: -9px; clip-path: path("M0 0 C0 8 4 12 10 14 L0 14 Z"); }
.sender { display: flex; gap: 4px; align-items: center; font-size: 14px; font-weight: 600; line-height: 18px; margin-bottom: 2px; white-space: nowrap; cursor: default; }
.sender svg { width: 14px; height: 14px; flex: none; }
.sender .sent-by { font-weight: 400; color: var(--color-text-secondary); }
.sender .topic-tag { margin-left: 6px; padding: 0 6px; border: 0; border-radius: 8px; background: var(--color-accent-soft); color: var(--color-accent); font: 500 12px/18px var(--font); cursor: pointer; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topicbar { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); scrollbar-width: none; }
.topicbar::-webkit-scrollbar { display: none; }
.sender.s-company { color: var(--color-side-company); }
.sender.s-client { color: var(--color-side-client); }
.sender.s-third_party { color: var(--color-side-third); }
.sender.s-none { color: var(--color-side-unknown); }
.mgroup > .avatar.tap { cursor: pointer; }
/* Время и галочки в правом нижнем углу пузыря, текст обтекает их, как в мессенджерах */
.room { display: inline-block; height: 1px; }
.meta { position: absolute; right: 8px; bottom: 4px; display: inline-flex; gap: 3px; align-items: center; font-size: 12px; line-height: 14px; color: var(--color-text-secondary); white-space: nowrap; user-select: none; }
.msg.out .meta { color: var(--color-time-out); }
.bubble > .meta { padding: 1px 6px; border-radius: 9px; background: rgba(0, 0, 0, .35); color: #fff !important; }
.bubble > .meta.block, .bubble:has(> .filecard) > .meta, .bubble:has(> .voice) > .meta { position: static; display: flex; justify-content: flex-end; gap: 4px; margin-top: 2px; background: none; color: var(--color-text-secondary) !important; padding: 0; }
.bubble > .meta .checks { color: inherit; }
.mark { font-style: italic; }
.checks { display: inline-flex; color: var(--color-time-out); }
.checks svg { width: 16px; height: 16px; }
.checks.read { color: var(--color-check-read); }
.deleted .bubble { opacity: .65; }
.quote { display: block; border-left: 3px solid var(--color-accent); padding: 1px 8px; margin: 2px 0 4px; border-radius: 4px; background: rgba(0, 0, 0, .04); font-size: 13px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; max-width: 360px; }
.media { display: block; max-width: min(340px, 100%); width: auto; max-height: 360px; height: auto; border-radius: calc(var(--bubble-radius) - 4px); margin: 2px 0; background: var(--color-surface-hover); }
.media.round { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; }
.filecard { display: flex; gap: 10px; align-items: center; padding: 4px 0; text-decoration: none; color: inherit; min-width: 200px; }
button.filecard { border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.filecard svg { width: 40px; height: 40px; flex: none; padding: 8px; border-radius: 50%; background: var(--color-accent); color: var(--color-on-accent); }
.filecard b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.filecard small { font-size: 13px; color: var(--color-text-secondary); }
.voice { display: flex; gap: 6px; align-items: center; }
.voice audio { height: 36px; width: 220px; max-width: 100%; min-width: 0; }
.voice small { white-space: nowrap; }
.speed { min-width: 36px; height: 24px; border-radius: 12px; border: 0; background: rgba(0, 0, 0, .08); cursor: pointer; font-size: 12px; font-weight: 600; }
.note { margin: 8px auto !important; padding: 6px 10px; border-radius: 10px; background: var(--color-note); border: 1px dashed var(--color-note-border); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 560px !important; }
.note .nhead { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 2px; }
.pending .bubble { opacity: .85; }
.pending .meta button, .failed .meta button { border: 0; background: none; color: var(--color-accent); font-weight: 600; cursor: pointer; font-size: 12px; padding: 0 2px; }
.failed .bubble { box-shadow: inset 0 0 0 1px var(--color-error); }
.failed .meta { color: var(--color-error); }
.older { align-self: center; width: auto !important; margin: 4px auto 8px !important; border-radius: 16px; background: var(--color-surface); }
.empty-chat { margin: auto; text-align: center; color: var(--color-text-secondary); padding: 24px; }
.msg .act {
  position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: rgba(0, 0, 0, .28); color: #fff; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.msg.in .act { right: -38px; }
.msg.out .act { left: -38px; }
.msg:hover .act, .msg:focus-within .act { opacity: 1; }
@media (hover: none) { .msg .act { display: none; } }
.act svg { width: 16px; height: 16px; }
.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--color-accent); } }

.msgmenu { position: fixed; z-index: 45; min-width: 200px; padding: 6px; border-radius: 12px; background: var(--color-surface); box-shadow: 0 4px 24px rgba(0, 0, 0, .2); display: grid; }
.msgmenu button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--color-text); }
.msgmenu button:hover, .msgmenu button:focus-visible { background: var(--color-surface-hover); }
.msgmenu .danger { color: var(--color-error); }
.reactbar { display: flex; gap: 2px; padding: 4px 6px 6px; border-bottom: 1px solid var(--color-border); margin-bottom: 4px; }
.msgmenu .reactbar button { width: 34px; height: 34px; min-height: 0; padding: 0; text-align: center; border-radius: 50%; font-size: 20px; line-height: 1; }
.msgmenu .reactbar button.on { background: var(--color-accent-soft, rgba(37, 99, 201, .15)); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 13px; border: 0; cursor: pointer;
  font: 600 13px/1 var(--font); background: rgba(0, 0, 0, .06); color: var(--color-accent); }
.reaction .emoji { font-size: 15px; }
.reaction.mine { background: var(--color-accent); color: var(--color-on-accent); }
.msgmenu-note { padding: 4px 12px 6px; font-size: 12px; color: var(--color-text-secondary); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: var(--color-error); }
.nav a[hidden] { display: none; }
.devices { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.devices li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dev-actions { display: inline-flex; gap: 6px; margin-left: auto; }
/* Сеансы в профиле: строки одной высоты, кнопка всегда справа, общие действия одной строкой ниже */
.sessions { list-style: none; margin: 0; padding: 0; display: grid; font-size: 14px; }
.sessions li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--color-border); }
.sessions li:first-child { border-top: 0; }
.sessions li > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sessions b { font-weight: 500; }
.sessions-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.guide { border-top: 1px solid var(--color-border); padding-top: 8px; }
.guide summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.guide .steps { margin: 8px 0 0; }
.bubble { cursor: default; }

/* Поле ввода: плавающая строка со скруглением и круглая кнопка справа */
.composer { flex: none; background: var(--color-composer-bg); padding: 6px 12px 10px; }
.composer > * { max-width: 760px; margin: 0 auto; }
.replybar { display: flex; gap: 8px; align-items: center; padding: 6px 8px 6px 12px; margin-bottom: 4px; border-left: 3px solid var(--color-accent); background: var(--color-input-bg); border-radius: 10px; font-size: 13px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.replybar[hidden] { display: none; }
.replybar div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replybar b { color: var(--color-accent); margin-right: 4px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.inputbar {
  flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 0; padding: 2px 4px; background: var(--color-input-bg);
  border: 1px solid var(--color-input-border); border-radius: var(--input-radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.composer.note-mode .inputbar { background: var(--color-note); border-color: var(--color-note-border); }
.inputbar textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; color: var(--color-text);
  min-height: 42px; max-height: 50vh; padding: 11px 6px; font: var(--msg-font)/1.35 var(--font);
}
.tool { width: 36px; height: 42px; flex: none; border-radius: 50%; border: 0; background: transparent; color: var(--color-text-secondary); display: grid; place-items: center; cursor: pointer; }
.tool:hover { color: var(--color-accent); }
.tool[aria-pressed="true"] { color: #b88a00; }
.tool svg { width: 24px; height: 24px; }
.sendbtn {
  width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--color-accent); color: var(--color-on-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.sendbtn svg { width: 24px; height: 24px; }
.sendbtn:disabled { opacity: .6; }
.from { display: flex; justify-content: center; gap: 4px; align-items: center; font-size: 12px; color: var(--color-text-secondary); margin-top: 4px !important; }
.from select { border: 0; background: transparent; font-size: 12px; color: var(--color-accent); font-weight: 600; padding: 0; cursor: pointer; }
.recbar { display: flex; gap: 10px; align-items: center; min-height: 48px; flex: 1; padding: 0 6px 0 14px; background: var(--color-input-bg); border-radius: var(--input-radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.recbar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-error); animation: pulse 1s infinite; }
.recbar .grow { flex: 1; font-size: 14px; }
.recbar .btn { border-radius: 18px; min-height: 36px; }
.vnote-wrap { position: fixed; inset: 0; z-index: 40; background: var(--color-overlay); display: grid; place-items: center; align-content: center; gap: 16px; padding: 16px; }
.vnote-wrap video { width: min(300px, 78vw); aspect-ratio: 1; border-radius: 50%; object-fit: cover; background: #000; transform: scaleX(-1); }
.vnote-wrap .recbar { flex: none; width: min(420px, 92vw); border-radius: 26px; }

/* Карточка: как «Информация» в Telegram */
.card-col .col-head { grid-template-columns: 1fr auto; align-items: center; height: 56px; border-bottom: 1px solid var(--color-border); }
.card-col .col-head h1 { font-size: 16px; }
.card-col .col-scroll { padding: 0 0 16px; display: grid; gap: 0; align-content: start; }
.profile { display: grid; justify-items: center; gap: 4px; padding: 20px 16px 16px; text-align: center; border-bottom: 8px solid var(--color-bg); }
.profile .avatar { width: 96px; height: 96px; font-size: 32px; }
.profile b { font-size: 18px; }
.kv { display: grid; gap: 2px; font-size: 14px; padding: 12px 16px; border-bottom: 8px solid var(--color-bg); }
.kv h2 { font-size: 13px; font-weight: 600; color: var(--color-accent); margin: 0 0 4px; }
.kv a { color: var(--color-accent); text-decoration: none; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.thumbs a { aspect-ratio: 1; overflow: hidden; background: var(--color-surface-hover); display: grid; place-items: center; font-size: 12px; color: var(--color-text-secondary); text-decoration: none; text-align: center; padding: 4px; overflow-wrap: anywhere; }
.thumbs a { position: relative; gap: 4px; align-content: center; }
.thumbs img, .thumbs video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumbs video.round { inset: 8%; width: 84%; height: 84%; border-radius: 50%; }
.thumbs small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.3; }
.thumb-icon { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--color-accent); color: var(--color-on-accent); justify-self: center; }
.thumb-icon svg { width: 18px; height: 18px; }
.thumbs video + .thumb-icon { background: rgba(0, 0, 0, .45); color: #fff; }
.member { display: grid; grid-template-columns: 40px 1fr; gap: 2px 10px; align-items: center; padding: 6px 0; }
.member .avatar { grid-row: 1 / 3; width: 40px; height: 40px; font-size: 14px; }
.member-name { display: flex; gap: 4px; align-items: center; font-weight: 600; font-size: 14px; min-width: 0; }
.member-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-name svg { width: 14px; height: 14px; flex: none; }
.members-admin { display: grid; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-border); font-size: 13px; }
.members-limit { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.members-limit .field { width: 80px; min-height: 32px; }
.members-export { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kv input[type="search"] { min-height: 36px; border-radius: 18px; }
.member-name .member-rank { margin-left: auto; padding-left: 8px; flex: none; max-width: 45%; font-weight: 400; font-size: 13px; color: var(--color-text-secondary); }
.inline-icon svg { width: 1em; height: 1em; vertical-align: -0.125em; }
.path .inline-icon { margin: 0 2px; }
.member-sub { font-size: 13px; color: var(--color-text-secondary); }
.member-edit { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px; }
.member select, .member input { min-height: 32px; font-size: 13px; border-radius: 16px; padding: 0 10px; }

/* Оформление */
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .themes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.theme-opt { border: 2px solid var(--color-border); border-radius: 14px; padding: 0; cursor: pointer; background: var(--color-surface); overflow: hidden; text-align: left; }
.theme-opt[aria-checked="true"] { border-color: var(--color-accent); }
.theme-opt .pv { height: 48px; padding: 8px; display: grid; gap: 4px; align-content: end; background-size: 120px auto, cover !important; }
.theme-opt .pv i { display: block; height: 12px; border-radius: 6px; width: 60%; }
.theme-opt .pv i + i { justify-self: end; width: 50%; }
.theme-opt span { display: block; padding: 6px 8px; font-size: 14px; font-weight: 600; color: var(--color-text); }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 14px; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--color-accent); }
.preview { padding: 12px; border-radius: 12px; background: var(--chat-bg); background-size: 240px auto, cover; display: grid; gap: 4px; }

@media (max-width: 1279px) {
  .inbox, .inbox.card-open { grid-template-columns: 320px minmax(0, 1fr); }
  .card-col { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100vw); z-index: 20; box-shadow: var(--shadow); }
}

/* Телефон: меню становится вкладками, строки сжимаются */
@media (max-width: 760px) {
  /* Меню внизу экрана: значок с подписью, как в приложениях на телефоне */
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .nav { order: 2; position: sticky; bottom: 0; z-index: 10; display: flex; align-items: stretch; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--color-border); }
  .brand, .nav-foot { display: none; }
  .main { padding: 16px; }
  .emp { grid-template-columns: auto 1fr; }
  .emp-actions { grid-column: 1 / -1; justify-content: stretch; }
  .emp-actions .btn { flex: 1; min-height: 44px; }
  .row { grid-template-columns: auto 1fr auto; }
  .row-time { display: none; }
  .seg { width: 100%; }
  .head > div, .head select { width: 100%; }
  .search, .addlink { flex-basis: 100%; }
  .seg button { flex: 1; min-height: 40px; padding: 0 4px; }
  .addlink .btn { min-height: 44px; }
  .inbox-mode .app { grid-template-rows: minmax(0, 1fr) auto; }
  .inbox-mode .main-col { height: auto; }
  .chat-mode .nav { display: none; }
  .chat-mode .app { grid-template-rows: minmax(0, 1fr); }
  .inbox, .inbox.card-open { grid-template-columns: minmax(0, 1fr); }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 0; font-size: clamp(10px, 2.9vw, 12px); text-align: center; }
  .chat-head { padding: 0 4px; gap: 6px; }
  .composer { padding: 6px 6px 8px; }
  .feed { padding: 6px 8px 8px; }
  .mstack { max-width: 86%; }
  .citem { margin: 0; width: 100%; border-radius: 0; }
  .inbox .chat, .inbox.chat-open .list { display: none; }
  .inbox.chat-open .chat { display: flex; }
  .back { display: inline-grid; }
  .status-pill { max-width: 104px; font-size: 12px; padding: 0 6px; }
  .card-col { top: 0; }
}

/* Поиск по сообщениям: подзаголовки разделов списка и выделение совпадения */
.list-sub { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); margin: 12px 16px 4px; }
.citem.hit .citem-last { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.citem.hit mark { background: var(--color-warn-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
#account-filter .mpick { width: 100%; margin-top: 8px; }
#account-filter .mpick-btn { min-height: 36px; }
/* Список выбора со значком мессенджера (mpick) */
.mpick { position: relative; display: inline-block; min-width: 0; max-width: 100%; }
.mpick-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer; background: var(--color-surface); color: var(--color-text); font: inherit; }
.mpick-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpick-chev { margin-left: auto; display: inline-grid; color: var(--color-text-secondary); }
.mpick-chev svg { width: 16px; height: 16px; }
.mpick-list { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 320px; overflow: auto; margin: 0; padding: 4px; list-style: none; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-s); box-shadow: var(--shadow); }
.mpick-list li { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.mpick-list li:hover, .mpick-list li:focus { background: var(--color-surface-hover); outline: none; }
.mpick-list li[aria-selected="true"] { color: var(--color-accent); font-weight: 600; }
.mdot { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; flex: none; color: var(--color-on-accent); }
.mdot svg { width: 14px; height: 14px; }
.mdot.m-telegram { background: var(--color-telegram); }
.mdot.m-whatsapp { background: var(--color-whatsapp); }
#account-filter:empty { display: none; }

/* Отправка от чужого аккаунта (Пр. «Интерфейс» 18): поле выделено, подпись нельзя скрыть */
.composer.foreign .inputbar { border-color: var(--color-warn); box-shadow: 0 0 0 1px var(--color-warn); }
.composer.foreign .from { color: var(--color-warn); font-weight: 500; }

.consents { gap: 6px; }
.consents .btn { justify-self: start; }

/* Разделы «Контроль» и «Настройки» */
.ctl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ctl-table th, .ctl-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); }
.ctl-table th { font-size: 12px; font-weight: 600; color: var(--color-text-secondary); }
.ctl-table td.num, .ctl-table th.num { text-align: right; }
.set-row { display: grid; gap: 6px; padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.set-row:last-child { border-bottom: 0; }
.work-cols { display: grid; gap: 0 40px; }
.work-cols > div { display: grid; align-content: start; min-width: 0; }
.work-cols .is-off .set-row { opacity: .55; }
@media (min-width: 1000px) { .work-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.set-row .set-key { font-size: 12px; color: var(--color-text-secondary); font-family: ui-monospace, monospace; }
.set-row .set-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* hidden сильнее любого display: иначе скрытый редактор часов виден и меняет часы незаметно */
[hidden] { display: none !important; }
.hours { display: grid; gap: 8px; }
.hours .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 360px; }
.hours .wday { min-height: 40px; padding: 0; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); color: var(--color-text); font: inherit; font-size: 13px; cursor: pointer; }
.hours .wday[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
/* Рабочие часы не шире карточки на любом телефоне: колонки сжимаются, поля занимают остаток строки */
.hours, .set-row > * { min-width: 0; }
.hours .time { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; max-width: 360px; }
.hours .tz { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: center; max-width: 360px; }
.hours select { width: 100%; min-height: 40px; }
/* Настройки админа: раздел раскрывается по нажатию на заголовок */
/* Настройки системы: карточки в две колонки на широком окне, «Рабочее время» — на всю ширину */
.adm-grid { display: grid; gap: 12px; align-items: start; }
@media (min-width: 1000px) { .adm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .adm-grid > .adm-work { grid-column: 1 / -1; } }
.adm-sec { padding: 16px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.adm-sec > h3 { font-size: 16px; font-weight: 600; margin: 0; }
.adm-body { display: grid; gap: 0; min-width: 0; }
.set-inline { grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; }
.set-inline > .secondary { grid-column: 1 / -1; }
.sub-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.sub-form .field { width: 100%; min-height: 44px; }
.sub-form .btn { min-height: 44px; }
/* Карточка сотрудника: строки входа и мессенджеров, опасные действия внизу */
/* Админка: два блока — сотрудники карточками и настройки системы */
.adm-block { display: grid; gap: 12px; }
.adm-block + .adm-block { margin-top: 28px; }
.adm-block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.adm-block-head h2 { font-size: 18px; margin: 0; }
/* Карточка сотрудника: профиль слева, мессенджеры справа, опасные действия внизу */
.emp-card { display: grid; gap: 16px; padding: 16px; }
.emp-grid { display: grid; gap: 16px 24px; }
@media (min-width: 1000px) { .emp-grid { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); } }
.emp-profile { display: grid; gap: 12px; align-content: start; }
.emp-top { display: flex; align-items: center; gap: 12px; }
.emp-top .avatar { width: 56px; height: 56px; font-size: 20px; }
.emp-name { font-size: 17px; margin: 0; }
.emp-sub { font-size: 13px; }
.emp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.emp-stat { display: grid; gap: 2px; padding: 8px; border-radius: var(--radius-s); background: var(--color-bg); text-align: center; }
.emp-stat b { font-size: 18px; }
.emp-stat span { font-size: 11px; color: var(--color-text-secondary); line-height: 1.2; }
.emp-stat.bad b { color: var(--color-error); }
.emp-field { display: grid; gap: 4px; font-size: 13px; color: var(--color-text-secondary); }
.emp-field .field { min-height: 40px; width: 100%; color: var(--color-text); }
.emp-login { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding-top: 12px; border-top: 1px solid var(--color-border); font-size: 14px; }
.emp-login .mlogo, .mrow .mlogo { width: 36px; height: 36px; border-radius: 10px; }
.emp-login .mlogo svg, .mrow .mlogo svg { width: 20px; height: 20px; }
.emp-card .perm { grid-column: auto; }
.emp-msgs { display: grid; gap: 8px; align-content: start; min-width: 0; }
.emp-msgs h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }
.mrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-m); }
.mrow-main { display: grid; gap: 4px; min-width: 0; font-size: 14px; }
.mrow-main .perm { font-size: 13px; }
.mrow-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) { .mrow { grid-template-columns: auto minmax(0, 1fr); } .mrow-actions { grid-column: 1 / -1; justify-content: stretch; } .mrow-actions .btn { flex: 1; } }
.emp-more summary { cursor: pointer; font-size: 14px; color: var(--color-text-secondary); min-height: 32px; display: flex; align-items: center; }
.emp-danger { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--color-border); }
.perm { grid-column: 2 / -1; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--color-text-secondary); }
.set-row textarea, .consents textarea, dialog textarea { font: inherit; }
.tg.m-whatsapp { color: var(--color-whatsapp); }
/* Мессенджеры: отдельная карточка на каждый, значок в цвете мессенджера */
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; max-width: 760px; }
.mcard { padding: 16px; display: grid; gap: 12px; align-content: start; }
.mcard-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.mcard-head h2 { font-size: 16px; margin: 0 0 4px; }
.mcard-note { margin: 0; font-size: 14px; }
.mlogo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--color-on-accent); }
.mlogo svg { width: 24px; height: 24px; }
.mlogo.m-telegram { background: var(--color-telegram); }
.mlogo.m-whatsapp { background: var(--color-whatsapp); }
.mlogo.m-login { background: var(--color-accent); }
.mcard-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Показатели в «Контроле»: плитка — число, подпись, пояснение */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; align-content: start; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-m); }
.stat b { font-size: 24px; line-height: 1.2; }
.stat span { font-size: 14px; }
.stat small { font-size: 12px; }
.mcard-extra { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mcard-extra:empty { display: none; }
.mcard-actions .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
