/* Manrope хранится на нашем сервере: не зависит от Google Fonts (в России он бывает недоступен) и не мигает при загрузке. */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/manrope-cyrillic-ext.woff2") format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/manrope-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/manrope-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/manrope-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ── UNOTE · «Аккуратный современный» ─────────────────────────────
   Спокойная нейтральная основа, один фиолетовый акцент (действия, выбор,
   свои сообщения) и три сигнальных цвета только для ожидания клиента.
   Шрифт — Manrope. Светлая и тёмная тема — одни и те же роли. */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --surface-3: #efeff3;
  --border: #e4e5ea;
  --border-soft: #eeeef2;
  --text: #16181d;
  --text-dim: #5f6470;
  --text-faint: #8a8f9b;
  --accent: #5b5bd6;
  --accent-soft: #efeffd;
  --accent-ink: #ffffff;
  --accent-btn: #5b5bd6;
  --accent-btn-hover: #4b4bc4;
  --ok: #2e9b69;
  --warn: #d98a12;
  --danger: #e5484d;
  --danger-soft: #fdeeef;
  --ok-ink: #1d7a50;      --ok-bg: #e9f6ef;      --ok-line: #a7dcc0;
  --warn-ink: #9a620a;    --warn-bg: #fdf5e6;    --warn-bg-2: #fcf1dc;  --warn-line: #f0d9a8;  --warn-hover: #fbefd6;
  --bad-ink: #c8323a;     --bad-ink-2: #a8262d;  --bad-bg: #fdf1f1;     --bad-line: #f5c9cb;   --bad-line-2: #f2c2c4;  --bad-hover: #fbe7e8;
  --info-ink: #4646b8;    --info-bg: #efeffd;
  --purple-ink: #6b4fbb;  --purple-bg: #f1ecfd;
  --cov-0: #fbe1e1;       --cov-1: #f6d99a;      --cov-2: #a7dcc0;
  --switch-off: #cfd1d8;
  --toast-bg: #1d1f25;
  --overlay: rgba(18, 19, 26, .42);
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 24, 29, .04), 0 1px 1px rgba(22, 24, 29, .02);
  --shadow-pop: 0 12px 32px -8px rgba(22, 24, 29, .22), 0 2px 6px rgba(22, 24, 29, .06);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

/* Тёмная тема. Включается атрибутом data-theme="dark" на <html> (theme.js). */
:root[data-theme="dark"] {
  --bg: #0e0f13;
  --surface: #16171c;
  --surface-2: #1b1c22;
  --surface-3: #24252d;
  --border: #2b2c35;
  --border-soft: #22232a;
  --text: #ececf1;
  --text-dim: #a3a6b4;
  --text-faint: #767987;
  --accent: #8e8ef5;
  --accent-soft: #24244a;
  --accent-ink: #ffffff;
  --accent-btn: #6363e0;
  --accent-btn-hover: #7171ea;
  --ok: #3fbf86;
  --warn: #e8a33a;
  --danger: #f0646a;
  --danger-soft: #3a1b1f;
  --ok-ink: #63d3a0;      --ok-bg: #15302a;      --ok-line: #2a6650;
  --warn-ink: #ecb65a;    --warn-bg: #33281a;    --warn-bg-2: #33281a;  --warn-line: #5b4520;  --warn-hover: #3a2e1c;
  --bad-ink: #f69a9e;     --bad-ink-2: #f69a9e;  --bad-bg: #2c171a;     --bad-line: #64303a;   --bad-line-2: #64303a;  --bad-hover: #351c20;
  --info-ink: #aeaef8;    --info-bg: #24244a;
  --purple-ink: #b79cf2;  --purple-bg: #2a2140;
  --cov-0: #4a2226;       --cov-1: #6b5320;      --cov-2: #2a6650;
  --switch-off: #3a3c48;
  --toast-bg: #2a2b34;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 14px 36px -8px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Кнопки ─────────────────────────────────────────────────────── */
button.primary {
  background: var(--accent-btn); color: var(--accent-ink); border: none;
  border-radius: 8px; padding: 9px 16px; font-weight: 500; font-size: 13.5px;
}
button.primary:hover { background: var(--accent-btn-hover); }
button.primary:disabled { opacity: .55; cursor: default; }
button.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 14px; font-size: 13.5px; font-weight: 500;
}
button.secondary:hover { background: var(--surface-2); }
button.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 7px; padding: 7px 12px; font-size: 12.5px;
}
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button.small { padding: 5px 10px; font-size: 12px; }
button.link-btn {
  background: none; border: none; color: var(--accent); font-size: 12.5px;
  padding: 0; text-decoration: none;
}
button.link-btn:hover { text-decoration: underline; }

/* ── Вход ───────────────────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 34px 32px; width: 100%; max-width: 380px; text-align: center; box-shadow: var(--shadow);
}
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.login-brand { display: block; height: 30px; max-width: 100%; margin: 4px auto 0; }
.login-card .login-sub { margin: 12px 0 26px; font-size: 12.5px; color: var(--text-faint); letter-spacing: .04em; }
.login-card .hint { color: var(--text-faint); font-size: 12.5px; line-height: 1.6; margin: 0; }
.login-card code { background: var(--surface-3); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
#login-form { display: flex; flex-direction: column; text-align: left; }
#login-form label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; }
#login-form input {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}
#login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#login-form button { margin-top: 4px; padding: 11px; font-size: 14px; }
.login-error {
  background: var(--danger-soft); border: 1px solid var(--bad-line-2); color: var(--bad-ink-2);
  border-radius: 8px; padding: 9px 11px; font-size: 12.5px; margin-bottom: 12px;
}
.login-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 16px; color: var(--text-faint); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ── Каркас ─────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 210px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px 20px; }
.sidebar-logo-img { height: 25px; width: auto; max-width: 100%; display: block; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  background: transparent; border: none; color: var(--text-dim); text-align: left;
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.sidebar-foot { border-top: 1px solid var(--border-soft); padding-top: 12px; }
.crm-switch { display: flex; gap: 2px; padding: 3px; margin-bottom: 12px; background: var(--surface-3); border-radius: 10px; }
.crm-switch[hidden] { display: none; }
.crm-switch > * { flex: 1; text-align: center; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 500; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-switch-cur { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); color: var(--text, inherit); }
.crm-switch-other { color: var(--text-faint, #6b7280); }
.crm-switch-other:hover { color: var(--text, inherit); }
.sidebar-user { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.sidebar-user-text { min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11.5px; color: var(--text-faint); }
.sidebar-foot button { width: 100%; }

.workspace { flex: 1; display: flex; overflow: hidden; }

/* ── Аватары ────────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 21px; }

/* ── Список чатов ───────────────────────────────────────────────── */
.list-panel {
  width: 340px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.list-filters { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.search-input, .select-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; color: var(--text);
}
.search-input:focus, .select-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.select-input { cursor: pointer; }

.list-tabs { display: flex; gap: 4px; padding: 0 14px 10px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.list-tab {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 6px 10px; border-radius: 7px; font-size: 12.5px; display: flex; align-items: center; gap: 6px;
}
.list-tab:hover { background: var(--surface-2); color: var(--text); }
.list-tab.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.list-tab .count { font-size: 11px; color: var(--text-faint); }
.list-tab.active .count { color: var(--accent); }

.chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-item {
  border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 11px 12px;
  margin-bottom: 7px; cursor: pointer; background: var(--surface); position: relative;
}
.chat-item:hover { border-color: var(--border); background: var(--surface-2); }
/* Два независимых сигнала, их нельзя смешивать:
   — пунктирная рамка = чат не распределён (лежит в общем пуле);
   — цвет фона = срочность: жёлтый от 20 минут ожидания, красный от 40.
   Не распределённый чат с коротким ожиданием — пунктир на белом фоне.
   Выбранная карточка отмечается рамкой, а не заливкой, иначе синий фон
   скрывал бы срочность. */
.chat-item.pool { border-style: dashed; border-color: var(--border); }
.chat-item.level-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.chat-item.level-warn:hover { background: var(--warn-hover); }
.chat-item.level-danger { background: var(--bad-bg); border-color: var(--bad-line); }
.chat-item.level-danger:hover { background: var(--bad-hover); }
.chat-item.selected {
  border-top-color: var(--accent); border-right-color: var(--accent); border-bottom-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.chat-item.selected:not(.level-warn):not(.level-danger) { border-left-color: var(--accent); }
.chat-item.selected:not(.level-warn):not(.level-danger) { background: var(--accent-soft); }
.chat-item-top { display: flex; gap: 10px; align-items: flex-start; }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-item .client { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .time { font-size: 11.5px; color: var(--text-faint); flex-shrink: 0; }
.chat-item .preview {
  font-size: 12.5px; color: var(--text-dim); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.chat-item-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2.5px 7px; border-radius: 5px;
  background: var(--surface-3); color: var(--text-dim);
}
.tag.manager { background: var(--info-bg); color: var(--info-ink); }
.badge-wait {
  font-size: 11px; font-weight: 500; padding: 2.5px 8px; border-radius: 20px;
  background: var(--danger-soft); color: var(--bad-ink); margin-left: auto;
}
.badge-wait.warn { background: var(--warn-bg-2); color: var(--warn-ink); }
.badge-wait.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-wait .clock { margin-right: 4px; }
.chat-item-meta { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.unread {
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 600;
  min-width: 17px; height: 17px; border-radius: 9px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-item .row-btn { margin-left: auto; }
.empty-list { padding: 40px 16px; color: var(--text-faint); font-size: 13px; text-align: center; }

/* ── Переписка ──────────────────────────────────────────────────── */
.thread-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.thread { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.thread-head { padding: 13px 18px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 11px; }
.thread-head-text { flex: 1; min-width: 0; }
.thread-head .name { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.thread-head .sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.pill {
  font-size: 11px; padding: 2.5px 8px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-dim); font-weight: 500;
}
.pill.repeat { background: var(--purple-bg); color: var(--purple-ink); }

.thread-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { max-width: 62%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--accent-btn); color: #fff; border-bottom-right-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--text-faint); font-size: 12px; max-width: 80%; text-align: center; }
.msg .meta { font-size: 10.5px; margin-top: 4px; opacity: .7; }

.thread-actions { display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.thread-reply { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--border-soft); align-items: flex-end; }
.thread-reply textarea {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; resize: none; line-height: 1.45; max-height: 160px;
}
.thread-reply textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.thread-reply-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.char-count { font-size: 11px; color: var(--text-faint); }
.char-count.over { color: var(--danger); font-weight: 500; }

/* ── Панель клиента и объявления ────────────────────────────────── */
.context-panel {
  width: 280px; flex-shrink: 0; background: var(--surface);
  border-left: 1px solid var(--border); padding: 18px 16px; overflow-y: auto;
}
.context-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding-top: 30px; }
.context-client { display: flex; flex-direction: column; align-items: center; text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.context-client .name { font-size: 15px; font-weight: 600; margin-top: 10px; }
.context-client .role { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.context-section { padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.context-section h4 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.ad-card { border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.ad-card .ad-title { font-size: 13px; font-weight: 500; padding: 10px 11px 4px; line-height: 1.35; }
.ad-card .ad-meta { font-size: 12px; color: var(--text-faint); padding: 0 11px 10px; }
.ad-card a { display: block; padding: 9px 11px; border-top: 1px solid var(--border-soft); color: var(--accent); font-size: 12.5px; text-decoration: none; }
.ad-card a:hover { background: var(--accent-soft); }
.history-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.history-item:last-child { border-bottom: none; }
.history-item .h-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.status-badge { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; font-weight: 500; }
.status-badge.won { background: var(--ok-bg); color: var(--ok-ink); }
.status-badge.lost { background: var(--surface-3); color: var(--text-faint); }
.status-badge.waiting { background: var(--danger-soft); color: var(--bad-ink); }
.status-badge.idle { background: var(--accent-soft); color: var(--info-ink); }
.status-badge.pool { background: var(--warn-bg-2); color: var(--warn-ink); }

/* ── Быстрые ответы ─────────────────────────────────────────────── */
.quick-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 9px; width: 38px; height: 38px; font-size: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.quick-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.quick-panel {
  display: flex; flex-direction: column; max-height: 320px;
  border-top: 1px solid var(--border-soft); background: var(--surface-2);
}
.quick-head { display: flex; gap: 8px; padding: 10px 18px; align-items: center; }
.quick-head .search-input { flex: 1; background: var(--surface); }
.quick-list { overflow-y: auto; padding: 0 10px 10px; }
.quick-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-faint); padding: 8px 8px 5px; font-weight: 600;
}
.quick-item {
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 3px; background: var(--surface);
}
.quick-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick-title { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.quick-score {
  font-size: 10px; font-weight: 500; padding: 1.5px 6px; border-radius: 4px;
  background: var(--ok-bg); color: var(--ok-ink);
}
.quick-text {
  font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.quick-empty { padding: 22px 12px; text-align: center; color: var(--text-faint); font-size: 12.5px; }
.quick-ai {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 12px;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; flex-wrap: wrap;
}
.quick-ai-note { font-size: 11.5px; color: var(--text-faint); }

.template-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.template-row:last-child { border-bottom: none; }
.template-main { flex: 1; min-width: 0; }
.template-title { font-size: 13.5px; font-weight: 500; }
.template-title .muted { font-weight: 400; color: var(--text-faint); font-size: 12px; }
.template-text { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.template-keys { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
.form-row textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; flex: 1; min-width: 260px;
  font-family: inherit; font-size: 13.5px; resize: vertical; line-height: 1.45;
}
.form-row textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.reply-locked {
  margin: 12px 18px 16px; padding: 11px 14px; border-radius: 9px;
  background: var(--surface-2); border: 1px dashed var(--border);
  color: var(--text-dim); font-size: 13px; text-align: center;
}

/* ── Смены ──────────────────────────────────────────────────────── */
.shift-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border-soft); font-size: 13px;
}
.shift-row:last-child { border-bottom: none; }
.shift-head { color: var(--text-faint); font-size: 12px; font-weight: 500; }
.shift-main { flex: 1; min-width: 0; }
.shift-name { font-weight: 500; }
.shift-sub { font-size: 11.5px; color: var(--text-faint); }
.shift-dur { text-align: right; font-variant-numeric: tabular-nums; }
.shift-row .c1 { flex: 1.6; min-width: 0; display: flex; align-items: center; gap: 8px; }
.shift-row .c2 { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }

/* ── Менеджеры: сводка и таблица ────────────────────────────────── */
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.panel-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-field { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.date-field input, .select-inline {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.select-inline { width: auto; min-width: 170px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 15px 17px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.kpi-value { font-size: 27px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi.good .kpi-value { color: var(--ok-ink); }
.kpi.warn .kpi-value { color: var(--warn-ink); }
.kpi.bad .kpi-value { color: var(--bad-ink); }
.kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.admin-panel .card-title { margin: 0 0 6px; font-size: 14.5px; }

.mgr-wrap { padding: 0; overflow-x: auto; }
.mgr-table { min-width: 1180px; }
.mgr-row {
  display: grid; align-items: center; gap: 16px; padding: 14px 20px;
  grid-template-columns: minmax(210px, 2.1fr) 100px minmax(160px, 1.1fr) minmax(150px, 1.3fr) minmax(170px, 1.5fr) minmax(120px, 1fr) 150px;
  border-bottom: 1px solid var(--border-soft);
}
.mgr-row:last-child { border-bottom: none; }
.mgr-row:not(.mgr-head):hover { background: var(--surface-2); }
.mgr-head {
  padding-top: 11px; padding-bottom: 11px; background: var(--surface-2);
  font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em;
  border-radius: 12px 12px 0 0;
}
.mgr-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mgr-avatar { position: relative; flex-shrink: 0; }
.mgr-avatar .dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--text-faint);
}
.mgr-avatar .dot.on { background: var(--ok); }
.mgr-who-text { min-width: 0; }
.mgr-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.mgr-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.35; }
.mgr-sub.warn { color: var(--bad-ink); }
.mgr-sub b { font-weight: 600; color: var(--text-dim); }
.mgr-sub b.neg { color: var(--bad-ink); }
.mgr-big { font-size: 20px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.mgr-actions { display: flex; gap: 6px; justify-content: flex-end; }
button.ghost.danger:hover { color: var(--bad-ink); border-color: var(--bad-line); background: var(--danger-soft); }

.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; font-variant-numeric: tabular-nums; }
.chip.good { background: var(--ok-bg); color: var(--ok-ink); }
.chip.warn { background: var(--warn-bg-2); color: var(--warn-ink); }
.chip.bad { background: var(--danger-soft); color: var(--bad-ink); }
.chip.mute { background: var(--surface-3); color: var(--text-faint); }

.bar { height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.bar + .mgr-sub { margin-top: 6px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--switch-off); border-radius: 22px; transition: background .2s; }
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── График работы ──────────────────────────────────────────────── */
.coverage { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; margin: 14px 0 6px; }
.cov { height: 26px; border-radius: 5px; background: var(--surface-3); position: relative; }
.cov.c0 { background: var(--cov-0); }
.cov.c1 { background: var(--cov-1); }
.cov.c2 { background: var(--cov-2); }
.cov.now::after {
  content: ""; position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; margin-left: -1px;
  background: var(--text); border-radius: 2px;
}
.coverage-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.coverage-note { font-size: 12.5px; color: var(--text-dim); margin-bottom: 16px; }
.coverage-note.warn { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 8px 12px; }
.coverage-note.ok { color: var(--ok-ink); }

.sched-scroll { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 10px; }
.sched-table { min-width: 940px; }
.sched-row {
  display: grid; align-items: center; gap: 8px; padding: 10px 14px;
  grid-template-columns: minmax(170px, 1.6fr) repeat(7, minmax(84px, 1fr)) 120px 90px;
  border-bottom: 1px solid var(--border-soft);
}
.sched-row:last-child { border-bottom: none; }
.sched-head { background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.sched-head .today { color: var(--accent); }
.sched-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sched-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-cell {
  font-size: 12px; text-align: center; padding: 5px 4px; border-radius: 7px; background: var(--surface-2);
  color: var(--text); display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums;
}
.sched-cell.off { background: transparent; color: var(--text-faint); }
.sched-cell.inactive { opacity: .5; }
.sched-cell.today { box-shadow: inset 0 0 0 1px var(--border); }
.sched-cell.live { background: var(--ok-bg); color: var(--ok-ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--ok-line); }
.sched-edit { text-align: right; }

/* ── Окно редактора ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--overlay); z-index: 120;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 620px; max-height: 100%;
  overflow-y: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; margin: 0; }
.switch-row { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; cursor: pointer; margin-bottom: 6px; }
.sm-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.sm-days { border: 1px solid var(--border-soft); border-radius: 10px; }
.sm-day { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); }
.sm-day:last-child { border-bottom: none; }
.sm-day.off { background: var(--surface-2); }
.sm-day-name { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; padding-top: 6px; cursor: pointer; }
.sm-off { color: var(--text-faint); font-size: 12.5px; display: inline-block; padding-top: 6px; }
.sm-times { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sm-time-line { display: flex; align-items: center; gap: 6px; }
.sm-time-line input[type="time"] {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 6px 8px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.sm-time-line input[type="time"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sm-foot-hint { margin: 12px 0 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.sm-error { flex: 1; color: var(--bad-ink); font-size: 12.5px; line-height: 1.4; }

/* ── Telegram ───────────────────────────────────────────────────── */
.tg-status { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.tg-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.tg-status .dot.on { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.tg-status.bad { color: var(--bad-ink-2); background: var(--danger-soft); border: 1px solid var(--bad-line-2); border-radius: 8px; padding: 10px 12px; font-weight: 400; }
.tg-status.off { color: var(--text-dim); }
.tg-steps { margin: 4px 0 14px; padding-left: 20px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.tg-steps code, .card code, .hint code { background: var(--surface-3); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.tg-fields { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.tg-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); flex: 1; min-width: 190px; }
.tg-fields input, #tg-token, #tg-public-url, #tg-link-input {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font-size: 13.5px; width: 100%;
}
.tg-fields input:focus, #tg-token:focus, #tg-public-url:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-hint { font-size: 11px; color: var(--text-faint); }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--text); cursor: pointer; margin: 4px 0; line-height: 1.4; }
.check-row input { margin-top: 3px; }
.url-suggest { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.url-label { font-size: 12px; color: var(--text-faint); }
.url-warn { flex-basis: 100%; font-size: 12.5px; color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 8px 12px; }
.url-chip { cursor: pointer; border: none; }
.url-chip:hover { background: var(--accent-soft); color: var(--accent); }
.tg-table { border: 1px solid var(--border-soft); border-radius: 10px; }
.tg-row { display: grid; grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1fr) auto; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); }
.tg-row:last-child { border-bottom: none; }
.tg-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tg-name { font-size: 13.5px; font-weight: 500; }
.tg-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.modal-narrow { max-width: 460px; }
.btn-link { text-decoration: none; display: inline-block; }
.sidebar-foot .link-btn { display: block; margin-bottom: 8px; text-align: left; }
@media (max-width: 780px) {
  .tg-row { grid-template-columns: 1fr; }
  .tg-actions { justify-content: flex-start; }
  .sidebar-foot .link-btn { display: inline; margin: 0; }
}
@media (max-width: 480px) { .sidebar-foot .link-btn { display: none; } }

/* ── Админ-панели ───────────────────────────────────────────────── */
.admin-panel { flex: 1; padding: 26px 30px; overflow-y: auto; background: var(--bg); }
.admin-panel h2 { font-size: 18px; margin-bottom: 6px; }
.admin-panel h3 { font-size: 14px; margin: 26px 0 8px; }
.form-hint { font-size: 12.5px; color: var(--text-dim); margin: 0 0 14px; line-height: 1.55; max-width: 620px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; box-shadow: var(--shadow); }
.manager-row, .store-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--border-soft); font-size: 13px; flex-wrap: wrap;
}
.manager-row:last-child, .store-row:last-child { border-bottom: none; }
.manager-row .name, .store-row .name { width: 150px; font-weight: 500; }
.manager-row .metric { color: var(--text-dim); min-width: 88px; font-variant-numeric: tabular-nums; }
.manager-row .login-tag, .store-row .muted { font-size: 11.5px; color: var(--text-faint); }
.shift-toggle { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.muted-tag { font-size: 10.5px; padding: 1.5px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-faint); margin-left: 4px; }
.poll-err { font-size: 11.5px; color: var(--bad-ink); max-width: 320px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.form-row input {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; min-width: 150px; flex: 1;
}
.form-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.update-banner {
  position: fixed; bottom: 20px; right: 20px; z-index: 110;
  background: var(--accent-btn); color: #fff; padding: 10px 14px 10px 18px; border-radius: 10px;
  font-size: 13px; align-items: center; gap: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.update-banner button {
  background: #fff; color: var(--accent); border: none; border-radius: 7px;
  padding: 6px 11px; font-size: 12.5px; font-weight: 500;
}

/* ── Уведомление ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--toast-bg); color: #fff; padding: 11px 18px; border-radius: 9px;
  font-size: 13px; z-index: 100; max-width: 520px; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.toast.error { background: var(--bad-ink-2); }

/* Узкие экраны: сначала убираем правую панель, потом ужимаем меню и список.
   Меню не схлопываем в иконки — иконок нет, подписи обрезались бы. */
@media (max-width: 1200px) { .context-panel { display: none !important; } }
@media (max-width: 1000px) {
  .sidebar { width: 158px; padding: 14px 8px; }
  .sidebar-logo-img { height: 20px; }
  .list-panel { width: 290px; }
  .admin-panel { padding: 20px 18px; }
}
@media (max-width: 780px) {
  .app { height: 100vh; height: 100dvh; min-height: 0; flex-direction: column; }

  /* Компактная шапка: логотип и пользователь в одну строку, меню — лентой с
     горизонтальной прокруткой под ними. */
  .sidebar {
    width: 100%; display: grid; grid-template-columns: auto 1fr;
    grid-template-areas: "brand foot" "nav nav"; align-items: center; gap: 8px 12px;
    padding: 10px 12px 8px; border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { grid-area: brand; padding: 0; }
  .sidebar-logo-img { height: 20px; flex-shrink: 0; }
  .sidebar-foot { grid-area: foot; display: flex; justify-content: flex-end; align-items: center; gap: 10px; border: none; padding: 0; }
  .sidebar-user { margin: 0; }
  .sidebar-user-text { display: none; }
  .sidebar-foot button { width: auto; }
  .sidebar-nav { grid-area: nav; flex: none; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .nav-item { flex-shrink: 0; white-space: nowrap; padding: 7px 12px; }

  /* Список и переписка — по очереди, а не друг под другом: открыли чат —
     видим чат, «назад» — снова список. */
  .workspace { flex-direction: column; min-height: 0; flex: 1; }
  .list-panel, .thread-panel { width: 100%; max-height: none; flex: 1; min-height: 0; border: none; }
  .workspace.chat-open .list-panel { display: none !important; }
  .workspace:not(.chat-open) .thread-panel { display: none !important; }
  .back-btn { display: inline-flex !important; }
  .msg { max-width: 86%; }
  .admin-panel { padding: 16px 14px; }
}
.back-btn { display: none; flex-shrink: 0; }
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi-value { font-size: 22px; }
  .panel-actions { width: 100%; }
}

/* ── Мой кабинет ────────────────────────────────────────────────── */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xl { width: 84px; height: 84px; font-size: 30px; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }

#login-form .remember-row { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 2px 0 14px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
#login-form .remember-row input { width: auto; margin: 0; padding: 0; accent-color: var(--accent-btn); }

.pf-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pf-info { flex: 1; min-width: 180px; }
.pf-name { font-size: 18px; font-weight: 600; }
.pf-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.pf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pf-h4 { margin: 14px 0 8px; font-size: 13px; font-weight: 600; }

.theme-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.theme-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2);
  color: var(--text); cursor: pointer; font: inherit;
}
.theme-card:hover { border-color: var(--accent); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.theme-card b { font-size: 13.5px; }
.theme-card span:not(.swatch) { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.swatch { width: 100%; height: 46px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 6px; }
.swatch-light { background: linear-gradient(#f4f6f8 0 30%, #fff 30% 100%); }
.swatch-dark { background: linear-gradient(#0e1116 0 30%, #161a20 30% 100%); }
.swatch-auto { background: linear-gradient(105deg, #f4f6f8 0 50%, #0e1116 50% 100%); }
.swatch-time { background: linear-gradient(90deg, #f4f6f8 0 35%, #0e1116 35% 100%); }
.theme-schedule { margin-top: 14px; font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.theme-schedule input[type="time"] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }

.sess-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.sess-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.sess-row.current { border-color: var(--ok-line); background: var(--ok-bg); }
.sess-icon { font-size: 20px; }
.sess-main { flex: 1; min-width: 0; }
.sess-name { font-size: 13.5px; font-weight: 500; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sess-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── Звонки ─────────────────────────────────────────────────────── */
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-badge { background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 10px; }
.neg { color: var(--bad-ink); }

.calls-filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.check-row.inline { margin: 0; align-items: center; }
.check-row.inline input { margin-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg-btn { background: transparent; border: none; color: var(--text-dim); padding: 7px 13px; font-size: 13px; border-right: 1px solid var(--border); }
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.call-row {
  display: grid; grid-template-columns: 96px minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(190px, 1.2fr);
  gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border-soft);
}
.call-row:last-child { border-bottom: none; }
.call-row.needed { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
.call-time { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.call-phone { font-weight: 600; font-size: 14.5px; color: var(--text); text-decoration: none; }
.call-phone:hover { color: var(--accent); }
.call-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.call-sub a { color: var(--accent); }
.call-act { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.call-done { font-size: 12.5px; color: var(--ok-ink); }

.cfg-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.cfg-row:last-child { border-bottom: none; }
.cfg-main { flex: 1; min-width: 0; }
.src-block { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 12px; background: var(--surface-2); }
.src-block .cfg-row { border-bottom: none; padding-top: 0; }
.src-url-label { display: block; font-size: 12px; color: var(--text-dim); margin: 6px 0; }
.src-url { flex: 1; min-width: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.src-details { margin-top: 10px; }
.src-details summary { cursor: pointer; font-size: 13px; font-weight: 500; padding: 4px 0; }
.map-fields label { min-width: 230px; }
.parse-sample { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.parse-ok { font-size: 13px; color: var(--ok-ink); background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: 8px; padding: 8px 12px; }
.recent-row { border-top: 1px solid var(--border-soft); padding: 8px 0; }
.recent-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.payload { margin: 6px 0 0; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; font-size: 11.5px; max-height: 130px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 900px) {
  .call-row { grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 14px; }
  .call-time { grid-column: 1 / 2; }
  .call-act { grid-column: 1 / -1; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .call-who { grid-column: 1 / -1; order: 0; }
  .src-url { min-width: 0; width: 100%; }
}

.call-player { grid-column: 1 / -1; }
.call-player audio { width: 100%; max-width: 520px; height: 36px; }

/* ── Лиды, статистика, рассылки, сделки ─────────────────────────── */
.lead-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); text-decoration: none; white-space: nowrap; }
.lead-chip:hover { text-decoration: underline; }
.modal-wide { max-width: 860px; }
.lead-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.lead-totals { display: flex; gap: 14px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.lead-totals b { color: var(--text); }
.lead-edit input { flex: 1; min-width: 160px; }
.lead-row { padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.lead-row:last-child { border-bottom: none; }
.timeline { display: flex; flex-direction: column; }
.tl-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.tl-row:last-child { border-bottom: none; }
.tl-ic { width: 22px; text-align: center; flex-shrink: 0; }
.tl-main { flex: 1; min-width: 0; }

.lead-list-row { display: grid; grid-template-columns: 70px minmax(180px, 1.6fr) 110px 170px minmax(140px, 1.2fr); gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.lead-list-row:hover { background: var(--surface-2); }
.lead-list-row:last-child { border-bottom: none; }
.ll-id { font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.ll-counts { font-size: 12.5px; color: var(--text-dim); }

.deal-line { display: grid; grid-template-columns: 1.1fr 1.6fr 64px 110px 34px; gap: 8px; margin-bottom: 8px; }
.deal-line input { min-width: 0; }
.reason-list { display: flex; flex-direction: column; gap: 4px; }
.reason-row { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.reason-row:hover { background: var(--surface-2); }
.check-group { display: flex; gap: 12px; flex-wrap: wrap; }

.st-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.st-cols .card { margin-bottom: 18px; }
.st-table { display: flex; flex-direction: column; overflow-x: auto; }
.st-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) minmax(130px, 1.1fr) 110px 120px 70px 70px 110px 120px; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); font-size: 13px; min-width: 860px; }
.st-row.st-src { grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 1fr) 140px 170px 120px 110px; min-width: 780px; }
.st-row.st-head { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em; }
.st-row:last-child { border-bottom: none; }
.hbar { height: 6px; border-radius: 4px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hbar span.good { background: var(--ok); } .hbar span.warn { background: var(--warn); } .hbar span.bad { background: var(--danger); }
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 150px; overflow-x: auto; padding-bottom: 4px; }
.vb { flex: 1; min-width: 14px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vb-col { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 1px; }
.vb-chats, .vb-calls { display: block; width: 70%; max-width: 30px; border-radius: 3px 3px 0 0; min-height: 0; }
.vb-chats { background: var(--accent); } .vb-calls { background: var(--warn); }
.vb-lbl { font-size: 10px; color: var(--text-faint); margin-top: 4px; }
.dot-chats, .dot-calls { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.dot-chats { background: var(--accent); } .dot-calls { background: var(--warn); }

.ai-progress .bar { height: 8px; }
.ai-q { font-size: 13px; color: var(--text-dim); margin: 14px 0 8px; }
.ai-summary { background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.55; margin-bottom: 12px; }
.ai-match { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface-2); }
.ai-match-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-reason { margin: 8px 0 4px; font-size: 13.5px; }
.ai-evidence { font-size: 12.5px; color: var(--text-dim); font-style: italic; margin-bottom: 8px; }
.hist-row { cursor: pointer; }
.hist-row:hover { background: var(--surface-2); }

.ml-card .ml-text { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 13px; white-space: pre-wrap; }
.ml-out { margin-top: 8px; }
.ml-prev { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

@media (max-width: 900px) {
  .st-cols { grid-template-columns: 1fr; }
  .lead-list-row { grid-template-columns: 60px 1fr; }
  .lead-list-row .ll-counts, .lead-list-row .ll-sales, .lead-list-row .ll-last { grid-column: 2; }
  .deal-line { grid-template-columns: 1fr 1fr; }
}
.tg-fields .check-group .check-row { flex-direction: row; min-width: 0; flex: none; align-items: center; }

/* ── Распределение ──────────────────────────────────────────────── */
.rules { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.6; }
.rules li { margin-bottom: 6px; }
.st-row.dist-row { grid-template-columns: minmax(160px, 1.4fr) 110px 110px 90px 110px 100px 130px; min-width: 780px; }
.st-row.dist-plan-row { grid-template-columns: minmax(160px, 1.4fr) 150px 150px minmax(180px, 1.4fr); min-width: 640px; }
.dist-after { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--text-dim); }
.filter-pair { display: flex; gap: 8px; }
.filter-pair .select-input { flex: 1; min-width: 0; }
.lead-owner { margin-bottom: 10px; }

.ar-days { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.ar-preview { margin: 12px 0; }
.ar-preview .ml-text { max-width: 420px; }
.ar-preview .ml-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 6px; }

/* ── Карточка клиента: ответственный и журнал ───────────────────── */
.ctx-facts { margin: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); row-gap: 9px; font-size: 13px; }
.ctx-facts dt { color: var(--text-dim); }
.ctx-facts dd { margin: 0; }
.ctx-muted { color: var(--text-faint); }
.ctx-sub { font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); padding: 1px 6px; margin-left: 4px; }
.ctx-event { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; line-height: 1.4; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.ctx-event .mono { color: var(--text-dim); padding-top: 1px; }

/* ── Скорость ответа по дням ────────────────────────────────────── */
.card-headline { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.card-headline .card-title { margin: 0; }
.rbars { display: flex; align-items: flex-end; gap: 6px; height: 230px; overflow-x: auto; padding-top: 4px; }
.rb { flex: 1; min-width: 26px; height: 100%; display: flex; flex-direction: column; align-items: center; }
.rb-val { height: 16px; font-size: 10.5px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rb-col { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--text); }
.rb-bar { display: block; width: 70%; max-width: 44px; min-height: 0; background: var(--text-faint); }
.rb-bar.good { background: var(--ok); } .rb-bar.warn { background: var(--warn); } .rb-bar.bad { background: var(--danger); }
.rb-day { margin-top: 5px; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rb-n { height: 14px; font-size: 10.5px; color: var(--text-faint); }

/* ── Меню: группы ───────────────────────────────────────────────── */
.sidebar-nav { gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; padding: 0 12px 6px; }
@media (max-width: 780px) {
  .sidebar-nav { gap: 4px; }
  .nav-group { display: contents; }
  .nav-group-title { display: none; }
}

/* ── Источники в статистике ─────────────────────────────────────── */
.src-item { padding: 14px 0; border-top: 1px solid var(--border); }
.src-item:first-child { border-top: none; padding-top: 4px; }
.src-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.src-name { font-size: 14.5px; font-weight: 600; }
.src-kind { font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 8px; }
.src-vol { font-size: 13px; }
.src-bar { margin: 9px 0 8px; height: 6px; }
.src-stats { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); align-items: center; margin-top: 8px; }
.ok-text { color: var(--ok-ink); }

/* ── Причины отказа: редактор ───────────────────────────────────── */
.rs-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 34px 34px 34px; gap: 8px; align-items: center; margin-bottom: 8px; max-width: 620px; }
.rs-row input { min-width: 0; }
.rs-n { color: var(--text-faint); text-align: right; }
.sidebar-nav { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
@media (max-width: 780px) { .sidebar-nav { overflow-y: visible; overflow-x: auto; } }

/* ── Причины отказа: список чатов по нажатию ────────────────────── */
.reason-link { display: flex; justify-content: space-between; align-items: center; width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; color: var(--text); font: inherit; font-size: 13px; padding: 9px 4px; cursor: pointer; text-align: left; }
.reason-link:hover { background: var(--surface-2); color: var(--accent); }
.reason-chat { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.rc-main { min-width: 0; flex: 1; }
.rc-last { margin-top: 5px; font-size: 12.5px; color: var(--text-dim); font-style: italic; }

/* ── Архив в меню, выделение нескольких чатов ─────────────────── */
.nav-count { float: right; margin-top: 1px; font-size: 11px; color: var(--text-faint); font-weight: 400; }
.nav-item.active .nav-count { color: inherit; opacity: .7; }
.list-title { padding: 2px 16px 10px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border-soft); }
.list-title-sub { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.list-tab-select {
  margin-left: auto; background: none; border: 1px solid var(--border-soft); color: var(--text-dim);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.list-tab-select:hover { color: var(--text); border-color: var(--border); }
.list-tab-select.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chat-item.selectable { cursor: pointer; }
.chat-item.picked { border-color: var(--accent); background: var(--accent-soft); }
.pick-box {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1;
  color: #fff; background: var(--surface); align-self: center; margin-right: 2px;
}
.chat-item.picked .pick-box { background: var(--accent); border-color: var(--accent); }
.bulk-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--surface-2); flex-wrap: wrap;
}
.bulk-count { font-weight: 600; font-size: 13px; }
.bulk-spacer { flex: 1; }
.status-badge.archived { background: var(--surface-3); color: var(--text-dim); }
.store-import { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.select-input.small { padding: 3px 6px; font-size: 12px; height: auto; }

/* ── Вложения в переписке: голосовые и фото ─────────────────────── */
.msg.has-media { max-width: min(360px, 80%); }
.msg-voice { display: flex; flex-direction: column; gap: 6px; }
.msg-voice-label { font-size: 12px; opacity: .85; }
.msg-voice audio { width: 260px; max-width: 100%; height: 36px; display: block; }
.voice-err { font-size: 12px; opacity: .8; }
.msg-image { display: block; }
.msg-image img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; }
.att-card {
  display: flex; gap: 10px; align-items: flex-start; text-decoration: none; color: inherit;
  background: rgba(127,127,127,.08); border: 1px solid rgba(127,127,127,.22); border-radius: 9px; padding: 8px 10px;
}
a.att-card:hover { border-color: var(--accent); }
.att-card img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.att-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.att-text b { font-weight: 600; overflow-wrap: anywhere; }
.att-sub { font-size: 12px; opacity: .8; overflow-wrap: anywhere; }
.att-domain { opacity: .65; }
.msg.out .att-card { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
.state-tag { font-size: 11px; color: var(--text-faint); white-space: nowrap; }


/* ════════════════════════════════════════════════════════════════════
   Облик D «Аккуратный современный»: компоненты
   ════════════════════════════════════════════════════════════════════ */
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
input, select, textarea { caret-color: var(--accent); }
.ico { width: 20px; height: 20px; flex-shrink: 0; display: block; }

/* Кнопки */
button.primary { border-radius: 10px; font-weight: 600; padding: 9px 16px; letter-spacing: .005em; transition: background .15s, transform .1s; }
button.primary:active { transform: translateY(1px); }
button.secondary { border-radius: 10px; font-weight: 600; }
button.ghost { border-radius: 9px; font-weight: 500; color: var(--text-dim); }
button.small { border-radius: 8px; }
.search-input, .select-input, .form-row input, .form-row textarea, .date-field input, .select-inline {
  border-radius: 10px; border-color: var(--border); background: var(--surface);
}
.search-input:focus, .select-input:focus, .form-row input:focus { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }

/* Меню */
.sidebar { width: 228px; padding: 18px 12px 14px; }
.sidebar-brand { padding: 2px 8px 22px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title { font-size: 11px; letter-spacing: .06em; font-weight: 600; padding: 0 12px 6px; }
.nav-item { padding: 8px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--text-dim); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sheet-close { display: none; }

/* Список чатов */
.list-panel { width: 352px; background: var(--bg); }
.list-filters { padding: 16px 14px 10px; }
.list-tabs { gap: 14px; padding: 0 14px; background: var(--bg); align-items: center; }
.list-tab { padding: 10px 0 11px; border: none; border-radius: 0; font-size: 13.5px; font-weight: 500; background: transparent; }
.list-tab:hover { background: transparent; color: var(--text); }
.list-tab.active { background: transparent; color: var(--text); font-weight: 650; box-shadow: inset 0 -2px 0 var(--accent); }
.list-tab .count { font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-dim); border-radius: 8px; padding: 1px 6px; }
.list-tab.active .count { background: var(--accent-soft); color: var(--accent); }
.list-tab-select { border-radius: 8px; font-weight: 600; }
.chat-list { padding: 10px 10px 16px; }

.chat-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 13px; margin-bottom: 8px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.chat-item:hover { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.chat-item.pool { border-style: dashed; border-color: color-mix(in srgb, var(--text-faint) 55%, var(--border)); }
.chat-item.level-warn, .chat-item.level-warn:hover { background: var(--surface); border-color: var(--warn-line); }
.chat-item.level-danger, .chat-item.level-danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }
.chat-item.selected, .chat-item.selected:not(.level-warn):not(.level-danger) {
  border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--surface);
}
.chat-item .client { font-size: 14px; font-weight: 650; }
.chat-item .preview { font-size: 13px; margin-top: 3px; }
.chat-item-foot { margin-top: 10px; gap: 6px; }
.tag { border-radius: 7px; font-weight: 500; background: var(--surface-3); }
.tag.manager { background: var(--accent-soft); color: var(--info-ink); }
/* Ожидание: точка и время цветом срочности, без плашки */
.badge-wait { background: none !important; padding: 0; font-size: 12px; font-weight: 700; color: var(--ok-ink); display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.badge-wait::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-wait .clock { display: none; }
.badge-wait.warn { color: var(--warn-ink); }
.badge-wait:not(.warn):not(.ok) { color: var(--bad-ink); }
.chat-item .row-btn.primary { padding: 6px 13px; font-size: 12.5px; }
.unread { background: var(--accent-btn); }
.state-tag { margin-left: auto; }

/* Аватары: мягкие квадраты */
.chat-item .avatar, .thread-head .avatar { border-radius: 11px; }

/* Переписка */
.thread-panel { background: var(--bg); }
.thread-head { background: var(--surface); padding: 12px 18px; border-bottom: 1px solid var(--border); }
.thread-head .name { font-size: 15px; font-weight: 700; }
.thread-messages { background: var(--bg); padding: 20px 22px; gap: 8px; }
.msg { border-radius: 16px; font-size: 14px; padding: 9px 13px 8px; max-width: min(560px, 68%); }
.msg.in { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.out { background: var(--accent-btn); color: #fff; border-bottom-right-radius: 5px; }
.msg .meta { font-size: 11px; opacity: .62; margin-top: 4px; }
.msg.system { font-size: 12px; color: var(--text-faint); }
.msg-voice-label { display: inline-flex; align-items: center; gap: 6px; }
.msg-voice-label .ico { width: 16px; height: 16px; }
.thread-actions { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 18px; }
.thread-reply { background: var(--surface); border-top: none; padding: 4px 18px 16px; gap: 8px; align-items: flex-end; }
.thread-reply textarea { border-radius: 14px; background: var(--surface-2); padding: 11px 14px; font-size: 14px; }
.thread-reply textarea:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-btn { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); color: var(--text-dim); }
.quick-btn .ico { width: 19px; height: 19px; }
#reply-submit { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px; border-radius: 12px; }
#reply-submit .send-ico { width: 18px; height: 18px; }
.reply-locked { border-radius: 12px; background: var(--surface); }
.quick-panel { background: var(--surface); }
.quick-item { border-radius: 10px; }

/* Карточка клиента */
.context-panel { background: var(--surface); border-left-color: var(--border); }
.context-section h4 { letter-spacing: .05em; color: var(--text-faint); font-size: 11px; }
.ad-card { border-radius: var(--radius); }

/* Разделы руководителя */
.admin-panel { padding: 28px 32px 40px; }
.admin-panel h2 { font-size: 22px; font-weight: 750; letter-spacing: -.015em; }
.card, .table-wrap, .kpi { border-radius: 14px; border-color: var(--border); }
.kpi-value { font-weight: 750; }
.chip { border-radius: 8px; }

/* Окна */
.modal { border-radius: 18px; box-shadow: var(--shadow-pop); border: 1px solid var(--border); }
.toast { border-radius: 12px; box-shadow: var(--shadow-pop); font-weight: 500; }

/* Нижняя панель — только на телефоне */
.mobile-nav { display: none; }

/* ════════════════════════════════════════════════════════════════════
   Телефон: один экран за раз, разделы внизу, поле ответа у края экрана
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 780px) {
  html, body { font-size: 15px; }
  /* iOS увеличивает страницу при фокусе на поле меньше 16px — не даём */
  input, select, textarea, .search-input, .select-input, .thread-reply textarea { font-size: 16px !important; }

  .app { flex-direction: column; height: 100dvh; }

  /* Меню целиком — по кнопке «Ещё», листом поверх экрана */
  .sidebar { display: none !important; }
  body.menu-open .sidebar {
    display: flex !important; position: fixed; inset: 0; z-index: 60; width: 100%;
    flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto; border: none; background: var(--surface); align-items: stretch;
  }
  body.menu-open .sidebar > * { width: 100%; }
  body.menu-open .sidebar-logo-img { height: 22px; align-self: center; }
  body.menu-open .sidebar-brand { display: flex; justify-content: space-between; flex-direction: row-reverse; padding: 4px 4px 18px; }
  body.menu-open .sheet-close {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  }
  body.menu-open .sidebar-nav { flex-direction: column; overflow: visible; gap: 2px; flex: none; }
  body.menu-open .nav-group { display: flex; margin-bottom: 16px; }
  body.menu-open .nav-group-title { display: block; padding: 0 14px 6px; }
  body.menu-open .sidebar-foot .link-btn { display: block; margin: 0 0 10px; font-size: 15px; }
  body.menu-open .nav-item { padding: 13px 14px; font-size: 16px; border-radius: 12px; }
  body.menu-open .sidebar-foot { display: block; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
  body.menu-open .sidebar-user-text { display: block; }
  body.menu-open .sidebar-foot button { width: 100%; padding: 12px; margin-top: 6px; }

  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav button {
    position: relative; background: none; border: none; color: var(--text-faint); padding: 5px 0 3px;
    display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav .ico { width: 23px; height: 23px; }
  .mobile-nav button.active { color: var(--accent); }
  .m-badge {
    position: absolute; top: 0; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
    background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  }
  .m-badge[hidden] { display: none; }

  /* Под нижнюю панель — отступ; в открытом чате панели нет */
  .workspace { flex: 1; min-height: 0; flex-direction: column; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .workspace.chat-open { padding-bottom: 0; }
  .app:has(.workspace.chat-open) .mobile-nav { display: none; }

  .list-panel, .thread-panel { width: 100%; flex: 1; min-height: 0; border: none; }
  .workspace.chat-open .list-panel { display: none !important; }
  .workspace:not(.chat-open) .thread-panel { display: none !important; }

  /* Фильтры: поиск на всю ширину, остальное — компактной строкой */
  .list-filters { flex-direction: row; flex-wrap: wrap; gap: 6px; padding: calc(12px + env(safe-area-inset-top)) 12px 8px; }
  .list-filters .search-input { flex: 1 1 100%; padding: 10px 13px; }
  .list-filters > select, .list-filters .filter-pair select { flex: 1 1 calc(50% - 3px); min-width: 0; padding: 8px 10px; font-size: 14px !important; }
  .list-filters .filter-pair { display: contents; }
  .list-tabs { padding: 0 14px; gap: 16px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .list-tabs::-webkit-scrollbar { display: none; }
  .list-tab { flex-shrink: 0; font-size: 14.5px; }
  .list-tab-select { flex-shrink: 0; }
  .chat-list { padding: 10px 10px 18px; }
  .chat-item { padding: 13px 14px; }
  .chat-item .client { font-size: 15.5px; }
  .chat-item .preview { font-size: 14px; }
  .chat-item .row-btn.primary { padding: 8px 16px; font-size: 14px; }
  .bulk-bar { padding-bottom: 12px; }

  /* Открытый чат: на весь экран */
  .thread-head { padding: calc(8px + env(safe-area-inset-top)) 10px 8px 6px; gap: 8px; position: relative; }
  .back-btn {
    display: inline-flex !important; align-items: center; justify-content: center; width: 40px; height: 40px;
    border: none; background: none; color: var(--accent); border-radius: 12px; padding: 0;
  }
  .back-btn .ico { width: 24px; height: 24px; }
  .thread-head .avatar { width: 36px; height: 36px; }
  .thread-head .name { font-size: 16px; }
  .thread-head .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-messages { padding: 14px 10px; }
  .msg { max-width: 84%; font-size: 15px; }
  .msg.has-media { max-width: 84%; }
  .thread-actions { padding: 8px 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .thread-actions::-webkit-scrollbar { display: none; }
  .thread-actions button { flex-shrink: 0; padding: 9px 14px; font-size: 14px; }
  .thread-reply { padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .thread-reply textarea { min-height: 44px; padding: 11px 14px; border-radius: 22px; }
  .quick-btn { width: 44px; height: 44px; border-radius: 22px; }
  .thread-reply-side { gap: 0; }
  .char-count:not(.over) { display: none; }
  #reply-submit { width: 44px; height: 44px; padding: 0; border-radius: 22px; justify-content: center; }
  #reply-submit .send-label { display: none; }
  .reply-locked { margin: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .quick-panel { max-height: 46vh; }

  /* Окна — листом снизу */
  .modal-backdrop { align-items: flex-end !important; padding: 0 !important; }
  .modal { width: 100% !important; max-width: none !important; border-radius: 20px 20px 0 0 !important; max-height: 92dvh; overflow-y: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important; }

  .admin-panel { padding: calc(16px + env(safe-area-inset-top)) 14px 24px; }
  .admin-panel h2 { font-size: 20px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); left: 12px; right: 12px; transform: none; max-width: none; text-align: center; }
}

/* ── Звонок на экране оператора ─────────────────────────────────── */
.live-call {
  position: fixed; top: 16px; right: 16px; z-index: 90; width: min(380px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
}
.live-call.ringing { border-color: var(--ok); animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: var(--shadow-pop), 0 0 0 0 color-mix(in srgb, var(--ok) 40%, transparent); } 50% { box-shadow: var(--shadow-pop), 0 0 0 7px color-mix(in srgb, var(--ok) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .live-call.ringing { animation: none; } }
.live-ico { width: 42px; height: 42px; border-radius: 12px; background: var(--ok-bg); color: var(--ok-ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.live-body { flex: 1; min-width: 0; }
.live-title { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.live-phone { font-size: 17px; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.live-sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 780px) { .live-call { top: calc(10px + env(safe-area-inset-top)); right: 12px; left: 12px; width: auto; } }

/* ── Статистика по объявлениям ──────────────────────────────────── */
.ls-list { display: flex; flex-direction: column; }
.ls-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 118px; gap: 14px; align-items: start; text-align: left;
  width: 100%; background: none; border: none; border-bottom: 1px solid var(--border-soft); padding: 14px 4px; color: inherit; font: inherit; cursor: pointer;
}
.ls-row:last-child { border-bottom: none; }
.ls-row:hover { background: var(--surface-2); }
.ls-rank { color: var(--text-faint); font-weight: 700; font-variant-numeric: tabular-nums; padding-top: 1px; }
.ls-title { font-weight: 650; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; overflow-wrap: anywhere; }
.ls-main .hbar { margin: 8px 0 6px; }
.ls-sub { font-size: 12.5px; color: var(--text-dim); }
.ls-reasons { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.ls-reasons span { font-size: 11.5px; padding: 2px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text-dim); }
.ls-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.ls-num { font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tr { font-size: 12px; font-weight: 700; color: var(--text-faint); }
.tr-up { color: var(--ok-ink); } .tr-down { color: var(--bad-ink); }
.flag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: .01em; }
.flag-hot { background: var(--ok-bg); color: var(--ok-ink); }
.flag-cold { background: var(--bad-bg); color: var(--bad-ink); }
@media (max-width: 560px) { .ls-row { grid-template-columns: 22px minmax(0, 1fr); } .ls-side { grid-column: 2; flex-direction: row; align-items: baseline; gap: 10px; justify-content: flex-start; } }

.mine-answered { display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.mine-answered input { accent-color: var(--accent-btn); }

/* ── Подсказки быстрых ответов над полем ввода ──────────────────── */
.thread-reply { position: relative; }
.quick-suggest {
  position: absolute; left: 18px; right: 18px; bottom: calc(100% - 2px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop);
  padding: 6px; max-height: 300px; overflow-y: auto;
}
.qs-item { padding: 8px 11px; border-radius: 9px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.qs-item b { font-size: 13.5px; font-weight: 650; }
.qs-item span { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-item.active, .qs-item:hover { background: var(--accent-soft); }
.qs-hint { font-size: 11px; color: var(--text-faint); padding: 6px 11px 3px; }
@media (max-width: 780px) { .quick-suggest { left: 8px; right: 8px; max-height: 40vh; } .qs-hint { display: none; } }

/* Переносы строк и пустые строки в сообщениях сохраняются, как в Avito */
.msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta, .msg .msg-voice, .msg .att-card, .msg .voice-slot { white-space: normal; }


/* ════════════════════════════════════════════════════════════════════
   Доводка: выпадающие списки, фильтры, карточка чата, пустые состояния
   ════════════════════════════════════════════════════════════════════ */

/* Свой значок у выпадающих списков: одинаково во всех браузерах и на телефоне, текст не «скачет» */
select, .select-input, .select-inline {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8f9b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
  padding-right: 34px !important; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  font-weight: 500; line-height: 1.3;
}
select:focus-visible { outline-offset: 0; }

/* Фильтры списка чатов: поиск + кнопка, остальное — сеткой */
.list-filters { flex-direction: column; gap: 8px; padding: 16px 14px 10px; }
.search-row { display: flex; gap: 8px; }
.search-row .search-input { flex: 1; min-width: 0; }
.filters-btn { display: none; position: relative; width: 44px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-dim); align-items: center; justify-content: center; padding: 0; }
.filters-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.f-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-btn); border: 2px solid var(--surface); box-sizing: content-box; }
.f-dot[hidden] { display: none; }
.filter-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-body .filter-pair { display: contents; }
.filter-body select { min-width: 0; width: 100%; }
.filter-body #store-filter:only-child, .filter-body > select:first-child:nth-last-child(2) { }

/* Карточка чата: время ожидания справа рядом с действием, а не посередине */
.chat-item-foot { gap: 8px; }
.chat-item-foot .badge-wait, .chat-item-foot .state-tag { margin-left: auto; }
.chat-item-foot .row-btn { margin-left: 0; }
.chat-item-foot .row-btn:not(.badge-wait + .row-btn):not(.state-tag + .row-btn) { margin-left: auto; }
.chat-item-foot .tag { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .row-btn.link-btn { font-weight: 600; font-size: 12.5px; padding: 4px 2px; }

/* «Показывать и отвеченные» — тихая строка под вкладками */
.mine-answered { padding: 9px 16px; border-bottom: none; background: var(--bg); font-weight: 500; }

/* Пустые списки */
.empty-list { padding: 56px 24px; color: var(--text-faint); font-size: 14px; line-height: 1.5; text-align: center; text-wrap: balance; }
.chat-list .empty-list::before {
  content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 14px; background: var(--surface-3);
  -webkit-mask: none; mask: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8f9b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7.5 12.5 3 3 6-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 24px;
}

@media (max-width: 780px) {
  .list-filters { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 12px 6px; }
  .list-filters .search-input { flex: 1 1 auto; padding: 11px 14px; }
  .filters-btn { display: inline-flex; height: 46px; width: 46px; }
  .filter-body { display: none; }
  .filter-body.open { display: grid; }
  .filter-body select { padding: 11px 12px; font-size: 15px !important; height: 44px; }
  .list-tab { font-size: 15px; }
  .mine-answered { padding: 8px 14px; font-size: 13.5px; }
}
.chat-item-foot { flex-wrap: nowrap; }
.chat-item-foot .tag { max-width: none; flex: 0 1 auto; min-width: 0; }
.chat-item-foot .badge-wait, .chat-item-foot .state-tag, .chat-item-foot .row-btn, .chat-item-foot .status-badge { flex-shrink: 0; }

.promo-out { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.promo-lead { font-size: 14px; margin-top: 4px; }
#promo-card { margin-bottom: 16px; }

.template-main { cursor: pointer; }
.template-text { white-space: pre-wrap; }
#tpl-text { width: 100%; min-height: 160px; }

.modal input[type="text"], .modal textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 14px; line-height: 1.5;
}
.modal textarea { resize: vertical; }
.modal input[type="text"]:focus, .modal textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .src-url-label { display: block; margin-bottom: 5px; }

.msg-del { background: none; border: none; padding: 0; font: inherit; color: inherit; opacity: .85; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.msg-del:hover { opacity: 1; }
.msg-del:disabled { opacity: .4; cursor: default; }

/* ── Отзывы ─────────────────────────────────────────────────────── */
.rv-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.rv-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow);
}
.rv-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.rv-top { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.rv-text { margin-top: 6px; font-size: 13.5px; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.rv-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.rv-amount { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.stars { display: inline-flex; gap: 1px; color: var(--border); }
.stars .star { width: 15px; height: 15px; }
.stars .star.on { color: var(--warn); }
.chip.info { background: var(--accent-soft); color: var(--info-ink); }
.rv-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 4px; }
.rv-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.rv-form label.rv-check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; color: var(--text); }
.rv-form input[type="checkbox"] { width: auto; accent-color: var(--accent-btn); }
.rv-timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.rv-step { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.rv-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--text-faint); }
.rv-dot.info { background: var(--accent); } .rv-dot.warn { background: var(--warn); } .rv-dot.good { background: var(--ok); } .rv-dot.bad { background: var(--danger); }
@media (max-width: 780px) { .rv-card { grid-template-columns: 1fr; gap: 8px; } .rv-side { align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; } .rv-form { grid-template-columns: 1fr; } }

#rv-sync-card { margin-bottom: 16px; }
.rv-chat { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 5px; max-height: 260px; overflow-y: auto; }
.rv-msg { font-size: 13px; padding: 6px 10px; border-radius: 10px; max-width: 88%; white-space: pre-wrap; overflow-wrap: anywhere; }
.rv-msg.in { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.rv-msg.out { background: var(--accent-soft); color: var(--text); align-self: flex-end; }

/* Доставка */
.dl-card { margin-bottom: 12px; }
.dl-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.dl-type { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 8px; }
.dl-contact { font-size: 17px; font-weight: 600; word-break: break-all; }
.dl-item { margin: 4px 0; }
.dl-note { margin: 6px 0; padding: 8px 10px; background: var(--surface-2); border-radius: 9px; white-space: pre-wrap; }
.dl-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.dl-dialog { margin-top: 10px; max-height: 320px; overflow: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.dl-msg { margin: 6px 0; }
.dl-msg.out > div { color: var(--text-dim); }

/* Объявление в карточке чата, заметка, автоподстановка */
.ad-card .ad-img { display: block; width: 100%; max-height: 190px; object-fit: cover; background: var(--surface-2); }
.ad-card .ad-img-link { padding: 0; border: 0; }
.ad-card .ad-price { font-size: 16px; font-weight: 700; padding: 0 11px 4px; }
.thread-note { margin: 0 16px 8px; padding: 9px 12px; background: var(--warn-bg-2); color: var(--warn-ink); border-radius: 10px; font-size: 13.5px; }
.thread-note .tn-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.thread-note .tn-head .link-btn { margin-left: auto; }
.thread-note .tn-text { white-space: pre-wrap; max-height: 120px; overflow: auto; margin-top: 3px; }
.reply-auto { margin: 0 16px 6px; padding: 6px 10px; background: var(--accent-soft); color: var(--accent); border-radius: 9px; font-size: 12.5px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }

/* ── Учёт: склад ─────────────────────────────────────────────────
   Плотные таблицы как в МойСклад/1С: липкая шапка, цветная полоска статуса слева, цифры по правому краю. */
.sk-panel .panel-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sk-scan { min-width: 320px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.sk-views { margin-bottom: 16px; }
.sk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.sk-bar .search-input { flex: 1; min-width: 200px; max-width: 380px; }
.sk-n { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--surface-3); color: var(--text-dim); font-size: 11.5px; font-weight: 700; text-align: center; }
.seg-btn.active .sk-n { background: var(--accent); color: var(--accent-ink); }
.sk-card { padding: 0; overflow: hidden; }
.sk-wrap { overflow: auto; max-height: calc(100vh - 330px); }
.sk-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.sk-table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-dim); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sk-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.sk-table .num { text-align: right; white-space: nowrap; }
.sk-table tbody tr:hover td { background: var(--surface-2); }
.sk-row { cursor: pointer; }
.sk-row td:first-child { box-shadow: inset 4px 0 var(--st-bar, transparent); padding-left: 14px; }
.sk-s-new { --st-bar: #f5c518; } .sk-s-released, .sk-s-built, .sk-s-free, .sk-s-in_stock { --st-bar: #2e9b69; }
.sk-s-repair_needed { --st-bar: #e5484d; } .sk-s-repairing, .sk-s-building { --st-bar: #f97316; }
.sk-s-reserve { --st-bar: #d6409f; } .sk-s-assembled { --st-bar: #5b5bd6; }
.sk-s-sold, .sk-s-written_off { --st-bar: #9aa0ab; }
.sk-s-sold td, .sk-s-written_off td { color: var(--text-faint); }
.sk-sku { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .02em; }
.sk-loc { display: inline-block; white-space: nowrap; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: 12px; }
.sk-sub { color: var(--text-faint); font-size: 12px; margin-top: 1px; }
.sk-todo { color: var(--warn-ink); font-size: 12px; margin-top: 2px; }
.sk-model { min-width: 220px; max-width: 420px; }
.sk-foot { padding: 8px 14px; color: var(--text-faint); font-size: 12px; border-top: 1px solid var(--border-soft); }
.sk-total td { font-weight: 800; background: var(--surface-2); }
.sk-locform { padding: 16px 18px; margin-bottom: 14px; }
.sk-locform .form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.sk-csv { margin-left: auto; text-decoration: none; padding: 8px 14px; border-radius: 9px; font-size: 13px; }
.sk-editor { max-width: 780px; }
.sk-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.sk-form .sk-w2 { grid-column: 1 / -1; }
.sk-f input, .sk-f select { box-sizing: border-box; }
.sk-extra { margin-top: 16px; }
.sk-block { margin-top: 14px; font-size: 13px; }
.sk-mini { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.sk-mini td { padding: 5px 8px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
@media (max-width: 760px) {
  .sk-scan { min-width: 0; width: 100%; }
  .sk-form { grid-template-columns: 1fr; }
  .sk-wrap { max-height: none; }
  .sk-csv { margin-left: 0; }
}

/* Пометки в переписке: закрыт / возвращён из закрытых */
.thread-mark { align-self: center; max-width: 85%; text-align: center; font-size: 12.5px; color: var(--text-dim); background: var(--surface-2); border-radius: 10px; padding: 6px 12px; margin: 6px 0; line-height: 1.45; }
.thread-mark.reopened { background: var(--accent-soft); color: var(--accent); }

/* Напоминания */
.rm-banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; width: min(720px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; }
.rm-banner-item { background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,.18); border-radius: 12px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.rm-banner-item .rm-text { flex: 1 1 260px; }
.rm-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.rm-card { margin-bottom: 12px; }
.rm-card.overdue { border-color: var(--accent); }
.rm-top { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.rm-when { font-weight: 700; }
.rm-body { white-space: pre-wrap; margin: 4px 0; }
.rm-presets { display: flex; gap: 6px; flex-wrap: wrap; }

/* Отложенные сообщения */
.sm-strip { margin: 0 16px 6px; display: flex; flex-direction: column; gap: 6px; }
.sm-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.sm-item.held { background: var(--warn-bg-2); color: var(--warn-ink); }
.sm-item .sm-main { flex: 1 1 240px; }
.sm-item .sm-text { color: var(--text-dim); margin-top: 2px; white-space: pre-wrap; }
.sm-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* Кто сейчас в чате */
.presence-bar { margin: 0 16px 6px; padding: 6px 12px; border-radius: 10px; font-size: 13px; background: var(--surface-2); color: var(--text-dim); }
.presence-bar.typing { background: var(--warn-bg-2); color: var(--warn-ink); font-weight: 600; }
.chat-item .pres { font-size: 11.5px; padding: 2px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-dim); white-space: nowrap; }
.chat-item .pres.typing { background: var(--warn-bg-2); color: var(--warn-ink); font-weight: 600; }

.chat-item-foot { flex-wrap: wrap; row-gap: 4px; }

/* Блокировка — в углу шапки чата, мелко, чтобы не нажать случайно */
.thread-head .thread-block { margin-left: auto; flex: none; width: 28px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid transparent; background: transparent; font-size: 13px; opacity: .35; cursor: pointer; }
.thread-head .thread-block:hover { opacity: 1; border-color: var(--border); background: var(--surface-2); }
.thread-head .thread-blocked { margin-left: auto; flex: none; font-size: 12px; color: var(--text-dim); background: var(--surface-2); border-radius: 8px; padding: 3px 8px; }
