/* Стиль 2И: цвета, шрифт Manrope и скругления — как в интерфейсе 2И (office.2i.pro).
   Тема: ?theme=light|dark (или #theme=…), запоминается на вкладку. */
@font-face {
  font-family: "Manrope Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/static/vendor/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 Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/static/vendor/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+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root, [data-theme="light"] {
  --bg: #ffffff; --panel: #f8f9fb; --surface: #ffffff;
  --line: #edeff2; --line-strong: #e4e7ee;
  --ink: #0f1115; --ink-2: #1b2430; --ink-3: #4a5260;
  --muted: #5c6570; --faint: #687080; --placeholder: #6b7380;
  --brand: #2d50e6; --brand-hover: #2845c8; --brand-soft: #e3e8fc; --brand-soft-2: #eef1fd; --brand-ink: #2649d9;
  --chip: #f1f3f7;
  --ok: #1f8a5b; --ok-soft: #e6f4ec; --ok-ink: #1c6e4c;
  --warn: #c46a12; --warn-soft: #fdf1e6; --warn-ink: #94450e;
  --neutral-soft: #ebedf2; --neutral-ink: #4a5260;
  --danger: #cc2f47; --danger-hover: #b4233a; --danger-soft: #fdecef; --danger-ink: #b4233a; --danger-line: #f3c4cc;
  --hl: #eef1fd;
  --bubble-in: #f1f3f7; --bubble-out: #e3e8fc; --bubble-auto: #fdf1e6; --note: #fffaeb; --note-line: #f1dc9c;
  --tg: #2aabee;
  --shadow: 0 1px 2px rgba(15, 17, 21, 0.05);
  --pop-shadow: 0 8px 28px rgba(15, 17, 21, 0.14), 0 0 0 1px rgba(15, 17, 21, 0.06);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #14161c; --panel: #181b22; --surface: #1c1f26;
  --line: #262b34; --line-strong: #2a2f39;
  --ink: #eef1f5; --ink-2: #dfe3ea; --ink-3: #b6bdc9;
  --muted: #9aa3b2; --faint: #949daf; --placeholder: #8a93a3;
  --brand: #4363e8; --brand-hover: #5574ee; --brand-soft: rgba(79, 110, 240, 0.2); --brand-soft-2: rgba(79, 110, 240, 0.13); --brand-ink: #8aa0f6;
  --chip: #22262f;
  --ok: #3fb880; --ok-soft: rgba(47, 154, 103, 0.18); --ok-ink: #5fd39b;
  --warn: #e9bc63; --warn-soft: rgba(233, 188, 99, 0.15); --warn-ink: #e9bc63;
  --neutral-soft: #262b34; --neutral-ink: #b6bdc9;
  --danger: #c93a4f; --danger-hover: #d8465a; --danger-soft: rgba(240, 106, 125, 0.16); --danger-ink: #f06a7d; --danger-line: rgba(240, 106, 125, 0.35);
  --hl: rgba(79, 110, 240, 0.16);
  --bubble-in: #22262f; --bubble-out: rgba(79, 110, 240, 0.24); --bubble-auto: rgba(233, 188, 99, 0.14); --note: rgba(233, 188, 99, 0.1); --note-line: rgba(233, 188, 99, 0.35);
  --shadow: none;
  --pop-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px #2a2f39;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Manrope Variable", Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.005em; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; margin: 28px 0 12px; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
code { background: var(--chip); border-radius: 6px; padding: 1px 6px; font-size: 13px; }

input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 15px; outline: none; min-width: 0;
}
textarea { height: auto; padding: 10px 14px; width: 100%; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--brand); }

.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.err { color: var(--danger-ink); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--panel); border-color: var(--line-strong); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.soft { background: var(--brand-soft-2); border-color: transparent; color: var(--brand-ink); }
.btn.soft:hover:not(:disabled) { background: var(--brand-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
.btn.ghost:hover:not(:disabled) { background: var(--chip); }
.btn.danger { color: var(--danger-ink); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-line); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .55; }
[data-theme="dark"] .btn.primary:disabled { opacity: .4; filter: saturate(.35); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; background: var(--chip); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-3); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* оболочка */
.layout { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
nav.side { border-right: 1px solid var(--line); background: var(--panel); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-weight: 700; font-size: 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
nav.side a {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--ink-3); font-weight: 600; font-size: 14px; cursor: pointer;
}
nav.side a:hover { background: var(--chip); color: var(--ink); }
nav.side a.on { background: var(--brand-soft-2); color: var(--brand-ink); }
nav.side a .ic { width: 18px; text-align: center; opacity: .9; }
nav.side a .badge { margin-left: auto; }
nav.side .grow { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }
main { overflow: auto; min-width: 0; background: var(--bg); }
.page { padding: 28px 32px 48px; max-width: 1160px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.page-head > .spacer { display: none; }
.btn-pair { display: inline-flex; gap: 8px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 20px; min-width: 20px; text-align: center; }
.badge.brand { background: var(--brand); }
.badge.muted { background: var(--neutral-soft); color: var(--neutral-ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; border-radius: 8px; padding: 2px 9px; background: var(--neutral-soft); color: var(--neutral-ink); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--danger-soft); color: var(--danger-ink); }
.pill.brand { background: var(--brand-soft-2); color: var(--brand-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.card { border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; background: var(--surface); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: transparent; }
tr:last-child td { border-bottom: 0; }
.table-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.table-card table th { background: var(--panel); }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--ink-2); color: #fff; padding: 10px 10px 10px 16px; border-radius: 12px; max-width: min(520px, calc(100vw - 24px)); z-index: 60; box-shadow: var(--pop-shadow); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.toast .x { border: 0; background: transparent; color: inherit; opacity: .7; width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; cursor: pointer; }
.toast .x:hover { opacity: 1; background: rgba(255,255,255,.12); }
.toast.err { background: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 17, 21, .35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 20px; padding: 24px; width: 480px; max-width: 100%; max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--pop-shadow); }
.modal h2 { margin: 0; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.qr { width: 232px; height: 232px; border-radius: 16px; background: #fff; padding: 8px; border: 1px solid var(--line); align-self: center; }
.steps { margin: 0; padding-left: 20px; color: var(--ink-3); font-size: 14px; }
.steps li { margin-bottom: 4px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }

/* чаты */
.chats { display: grid; grid-template-columns: 360px 1fr; height: 100vh; }
@media (min-width: 1280px) { .chats { grid-template-columns: 410px 1fr; } }
.feed { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.feed-head { padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.search { position: relative; }
.search input { width: 100%; padding-left: 38px; background: var(--panel); border-color: transparent; }
.search::before { content: ""; position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); background: var(--faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") center / contain no-repeat; pointer-events: none; }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--faint); width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.search .clear:hover { background: var(--chip); color: var(--ink-2); }
.search:has(.clear) input { padding-right: 36px; }
.tabs { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; height: 32px; padding: 0 10px; border-radius: 10px; font-weight: 600; font-size: 13px; color: var(--ink-3); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { background: var(--chip); }
.tabs button.on { background: var(--brand-soft-2); color: var(--brand-ink); }
.more-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-filters select, .more-filters input { height: 38px; font-size: 13.5px; border-radius: 10px; }
.list { overflow: auto; flex: 1; }
.item { padding: 12px 16px; cursor: pointer; display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 12px; align-items: center; border-bottom: 1px solid var(--line); }
.item:hover { background: var(--panel); }
.item.on { background: var(--hl); }
.item .avatar { grid-row: span 2; width: 40px; height: 40px; font-size: 15px; }
.item .t { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .p.err { color: var(--danger-ink); }
.item .p { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.item .time { font-size: 12px; color: var(--faint); text-align: right; }
.item .right { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.item .who-small { grid-column: 2 / 4; font-size: 12px; color: var(--faint); }
.conv { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.conv-head { padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; background: var(--surface); flex-wrap: wrap; min-height: 68px; }
.conv-head .title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.conv-head .sub { color: var(--muted); font-size: 13px; }
.conv-sub { padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msgs { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 12px; color: var(--faint); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px; margin: 10px 0 4px; }
.msg { max-width: min(72%, 560px); padding: 8px 12px 6px; border-radius: 16px 16px 16px 6px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.msg.out { background: var(--bubble-out); border-color: transparent; align-self: flex-end; border-radius: 16px 16px 6px 16px; }
.msg.auto { background: var(--bubble-auto); }
.msg .sticker { display: block; width: 160px; height: 160px; object-fit: contain; }
.conv { position: relative; }
.conv-head .head-main { min-width: 0; flex: 1 1 0; }
.conv-head .head-main .title, .conv-head .head-main .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop-zone { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--brand) 12%, transparent); border: 2px dashed var(--brand); border-radius: 12px; color: var(--brand); font-weight: 700; font-size: 16px; }
.msgs-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.to-bottom { position: absolute; right: 18px; bottom: 14px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); box-shadow: 0 4px 14px rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.to-bottom .badge { position: absolute; top: -6px; right: -6px; }
.unread-line { display: flex; align-items: center; gap: 10px; color: var(--brand); font-size: 12.5px; font-weight: 600; margin: 6px 0; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--brand) 40%, transparent); }
.msg a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg.out a { color: inherit; }
.msg.sticker { background: transparent !important; border-color: transparent !important; padding: 0; position: relative; }
.msg.sticker .meta { position: absolute; right: 4px; bottom: 4px; margin: 0; padding: 1px 7px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff; }
.msg.sticker .meta .read { color: #fff; }
.draft { color: var(--danger-ink); }
.signals { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 16px; }
.signals > b, .signals > .faint { flex-basis: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.typing { color: var(--brand) !important; font-style: italic; }
.msg .svc { color: var(--muted); font-style: italic; }
.msg.internal { background: var(--note); border: 1px dashed var(--note-line); align-self: center; font-size: 13.5px; border-radius: 12px; max-width: 80%; }
.msg.deleted { opacity: .6; }
.msg.error { border: 1px solid var(--danger-line); }
.msg .meta { font-size: 11.5px; color: var(--faint); margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.msg .meta .read { color: var(--brand); font-weight: 700; }
.msg .sender { font-size: 12.5px; font-weight: 700; color: var(--brand-ink); margin-bottom: 2px; }
.msg .src { font-weight: 600; }
.msg img.att { max-width: 280px; max-height: 280px; border-radius: 10px; display: block; margin: 4px 0; cursor: zoom-in; }
.msg audio, .msg video { max-width: 300px; display: block; margin: 4px 0; }
.msg .file { display: inline-flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--chip); margin: 2px 0; color: var(--ink-2); }
.compose { border-top: 1px solid var(--line); padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.compose textarea { min-height: 64px; max-height: 220px; border-radius: 14px; }
.compose .tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border: 0; border-radius: 10px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.chip:hover { background: var(--brand-soft-2); color: var(--brand-ink); }
.note-box { display: flex; gap: 8px; }
.note-box input { flex: 1; height: 38px; font-size: 13.5px; background: var(--note); border-color: var(--note-line); }

/* аналитика */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
@media (max-width: 1023px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; background: var(--surface); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .l { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chart { border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; background: var(--surface); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bars .col { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; max-width: 32px; height: 100%; }
.bars .col:hover .seg-in { filter: brightness(1.12); }
.bars { justify-content: space-around; }
.bars .seg-in { background: var(--brand); border-radius: 4px 4px 0 0; }
.bars .seg-out { background: var(--brand-soft); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.week { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.week .iv { flex-wrap: nowrap; min-width: 0; gap: 6px; }
.week .iv { flex-wrap: wrap; }
.week .iv .pair { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.week .iv input[type=time] { width: 96px; min-width: 96px; padding: 0 8px; }
.week .iv { gap: 4px; }
.week .iv .btn.icon { width: 32px; min-width: 32px; padding: 0; }
.week .iv input[type=time]::-webkit-calendar-picker-indicator { display: none; }

.axis { display: flex; gap: 4px; margin-top: 6px; }
.axis span { flex: 1; min-width: 4px; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: visible; }
.legend i.out { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.bars .seg-out { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 35%, transparent); }
nav.side a .ic { display: inline-flex; }
nav.side a .short { display: none; }

/* 1024: меню — иконками с подсказками */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 68px 1fr; }
  nav.side { padding: 14px 10px; align-items: stretch; }
  nav.side .label { display: none; }
  nav.side .brand { padding: 0 0 14px; justify-content: center; }
  nav.side a { justify-content: center; padding: 0; position: relative; }
  nav.side a .badge { position: absolute; top: 2px; right: 2px; margin: 0; min-width: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
  nav.side .who { justify-content: center; padding: 6px 0; }
  nav.side .who { flex-direction: column; gap: 6px; }
  nav.side .who .logout { margin-left: 0; }
  .chats { grid-template-columns: 340px 1fr; }
  .tabs button { padding: 0 8px; font-size: 12.5px; }
}
/* 768 и меньше: нижнее меню с подписями, один столбец */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 100dvh; }
  main { grid-row: 1; }
  nav.side { grid-row: 2; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; overflow-x: auto; }
  nav.side .brand, nav.side .grow, nav.side .who { display: none; }
  nav.side a { flex-direction: column; height: 52px; gap: 2px; padding: 0 2px; min-width: 50px; flex: 1; font-size: 10.5px; font-weight: 600; }
  nav.side a .label { display: none !important; }
  nav.side a .short { display: block; white-space: nowrap; }
  nav.side a.theme-btn { display: none; }
  nav.side a .badge { top: 0; right: 6px; }
  .chats { grid-template-columns: 1fr; height: calc(100dvh - 61px); }
  .chats.open .feed { display: none; }
  .chats:not(.open) .conv { display: none; }
  .hide-sm { display: none !important; }
  .conv-head { padding: 8px 12px; min-height: 56px; gap: 8px; flex-wrap: nowrap; }
  .conv-head .title { font-size: 15px; }
  .conv-head .avatar.lg { width: 34px; height: 34px; font-size: 13px; }
  .conv-head .pill { display: none; }
  .conv-head .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .msgs { padding: 12px; }
  .msg { max-width: 88%; }
  .toast { top: calc(8px + env(safe-area-inset-top)); left: 12px; right: 12px; transform: none; max-width: none; }
  .page { padding: 18px 14px 32px; }
  .page-head .btn { width: 100%; }
  /* аккаунты — карточками */
  .acc-table table, .acc-table tbody, .acc-table tr, .acc-table td { display: block; width: 100%; }
  .acc-table thead { display: none; }
  .acc-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .acc-table td { border: 0; padding: 4px 0; }
  .acc-table td[data-l]::before { content: attr(data-l) ": "; color: var(--faint); font-size: 12.5px; margin-right: 4px; }
  .acc-table td[data-l] { display: flex; align-items: center; }
  .acc-table td .row { justify-content: flex-start !important; }
  .modal { padding: 18px; border-radius: 18px; }
  .week { grid-template-columns: 1fr; gap: 4px 0; }
  
  .kpi .v { font-size: 22px; }
}
.mobile-back { display: none; }
@media (max-width: 820px) { .mobile-back { display: inline-flex; } }


/* ответ на сообщение, цитата, длинные сообщения */
.msg { position: relative; }
.msg-acts { position: absolute; top: 50%; transform: translateY(-50%); left: calc(100% + 6px); display: flex; gap: 4px; z-index: 3; }
.msg.out .msg-acts { left: auto; right: calc(100% + 6px); flex-direction: row-reverse; }
.msg-act { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-3); display: none; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.msg-act.danger:hover { color: var(--danger-ink); }
.msg:hover .msg-act, .msg-act:focus-visible, .msg.act-open .msg-act, .msg:focus-within .msg-act { display: inline-flex; }
.msg:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (hover: none) { .msg-acts { display: none !important; } }   /* на телефоне — меню по тапу на пузырь */
.act-sheet .react-row { display: flex; justify-content: space-around; padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.act-sheet .react-row button { border: 0; background: none; font-size: 26px; width: 44px; height: 44px; border-radius: 50%; }
.act-sheet a.danger { color: var(--danger-ink); }
.fwd-list a.on { background: var(--brand-soft-2); color: var(--brand-ink); font-weight: 600; }
.fwd input + .faint, .fwd .fwd-list + input { margin-top: 6px; }
.msg.editing { outline: 2px solid var(--brand); outline-offset: 2px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; }
.menu a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-size: 14px; }
.menu a:hover { background: var(--panel); }
.menu a.danger { color: var(--danger-ink); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.acc-table { overflow: visible; }
.acc-table thead th:first-child { border-top-left-radius: 16px; } .acc-table thead th:last-child { border-top-right-radius: 16px; }
.presence.on { color: var(--ok-ink, #1a8f4e); }
.search-bar input { flex: 1; min-width: 140px; height: 34px; }
.msg.hit { box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.msg.hit-cur { box-shadow: 0 0 0 2px var(--brand); }
.voice-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.voice-bar audio { height: 34px; max-width: 100%; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.emoji-pop { left: auto; right: 0; top: auto; bottom: calc(100% + 6px); width: 300px; max-width: calc(100vw - 32px); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin: 4px 0 8px; }
.emoji-grid button { border: 0; background: none; font-size: 21px; height: 34px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--panel); }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.msg a[href^="tel:"] { white-space: nowrap; word-break: normal; }
.older { align-self: center; margin-bottom: 8px; }
.audio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-row audio { max-width: 100%; min-width: 0; }
.audio-row span { white-space: nowrap; }
.conv-head .pill { flex-shrink: 0; }
.react-wrap { position: relative; display: inline-flex; }
.react-pop { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.14); z-index: 40; }
.react-pop button { border: 0; background: none; font-size: 20px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.react-pop button:hover { background: var(--panel); transform: scale(1.15); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reactions button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 1px 8px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.reactions button.mine { border-color: var(--brand); background: var(--brand-soft-2); color: var(--brand-ink); }
.show-xs, .show-xs-flex { display: none !important; }
.xs-state .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 4px; vertical-align: middle; }
.xs-state.bad { color: var(--danger-ink); } .xs-state.warn { color: var(--warn-ink); } .xs-state.ok { color: var(--ok-ink); }
.msg mark { background: color-mix(in srgb, var(--warn, #f5b400) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
@media (max-width: 480px) {
  .hide-xs { display: none !important; }
  .show-xs { display: inline !important; }
  .menu a.show-xs-flex { display: flex !important; }
}
.fwd input { width: 100%; }
.fwd-list { max-height: 320px; overflow: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; }
.fwd-list a { display: block; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fwd-list a:last-child { border-bottom: 0; }
.fwd-list a:hover { background: var(--panel); }
.msg a.link-card { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--brand); background: var(--brand-soft-2); border-radius: 6px; text-decoration: none; color: var(--ink-2); word-break: normal; font-size: 13px; }
.link-card .site { color: var(--brand-ink); font-weight: 600; font-size: 12.5px; }
.link-card .desc { color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.head-right { text-align: right; line-height: 1.35; max-width: 280px; min-width: 0; }
.head-right > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { position: relative; }
.who .logout { margin-left: auto; flex-shrink: 0; }
.alert-list { padding: 4px; }
.alert-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; }
.alert-row + .alert-row { border-top: 1px solid var(--line); }
.alert-row:hover { background: var(--panel); }
.alert-row .ic { color: var(--ink-3); flex-shrink: 0; display: inline-flex; }
.alert-row .txt { flex: 1; min-width: 0; }
.alert-row .meta { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.audit-cards { display: none; }
.audit-cards .card { padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 480px) {
  .alert-row { flex-wrap: wrap; }
  .alert-row .txt { flex-basis: calc(100% - 40px); }
  .alert-row .meta { width: 100%; justify-content: space-between; padding-left: 36px; }
  .page .table-card:has(+ .audit-cards) { display: none; }
  .audit-cards { display: block; }
}
.people-block { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.people-block > .row { margin-bottom: 8px; }
.people-row { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.people-row .grow { flex: 1; min-width: 200px; }
.people-row .acts { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; justify-content: flex-end; margin-left: auto; }
.people-row.off { opacity: .6; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; }
.link-box input { width: 100%; font-family: ui-monospace, monospace; font-size: 12.5px; }
.pin-mark { color: var(--ink-3); display: inline-flex; }
.quote { border-left: 3px solid var(--brand); background: var(--brand-soft-2); border-radius: 6px; padding: 4px 8px; margin: 2px 0 6px;
  font-size: 13px; color: var(--ink-3); cursor: pointer; display: flex; flex-direction: column; max-width: 100%; overflow: hidden; }
.quote b { color: var(--brand-ink); font-size: 12px; }
.msg.out .quote { background: rgba(255,255,255,.45); }
[data-theme="dark"] .msg.out .quote { background: rgba(0,0,0,.18); }
.clamp { display: -webkit-box; -webkit-line-clamp: 15; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { border: 0; background: none; color: var(--brand); padding: 2px 0; font-weight: 600; font-size: 13px; }
.msg.flash { box-shadow: 0 0 0 3px var(--brand-soft); transition: box-shadow .2s; }
.reply-bar { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-left: 3px solid var(--brand); background: var(--brand-soft-2); border-radius: 8px; font-size: 13.5px; color: var(--brand-ink); }
.reply-bar b { color: var(--brand-ink); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel); }
.show-sm, .show-sm-flex, .show-md { display: none !important; }

/* панель «Ещё» на телефоне */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,17,21,.35); z-index: 45; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; border-radius: 20px 20px 0 0; padding: 14px 12px calc(76px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--pop-shadow); }
.sheet a { display: flex; gap: 12px; align-items: center; height: 48px; padding: 0 12px; border-radius: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.sheet a:hover, .sheet a.on { background: var(--brand-soft-2); color: var(--brand-ink); }
.sheet .who { padding: 6px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; gap: 10px; align-items: center; }

@media (max-width: 1180px) {
  .conv-head { flex-wrap: nowrap; }
  .conv-head .sub.hide-md { display: none !important; }
  .show-md { display: inline !important; }
}
@media (max-width: 820px) {
  .show-sm { display: inline !important; }
  nav.side a.show-sm-flex { display: flex !important; }
  .menu a.show-sm-flex { display: flex !important; }
  nav.side a.not-sm { display: none; }
  nav.side { position: relative; z-index: 46; background: var(--panel); }
  .conv-head .pill { display: inline-flex; font-size: 11.5px; padding: 1px 7px; }
  .msg-acts { left: calc(100% + 4px); }
  .msg.out .msg-acts { right: calc(100% + 4px); left: auto; }
}

.ch-mark { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; border-radius: 5px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; background: color-mix(in srgb, var(--tg) 14%, transparent); color: #085d8e; }
.ch-mark.max { background: color-mix(in srgb, #7b5cff 14%, transparent); color: #5333d6; }
[data-theme="dark"] .ch-mark { color: #6cc4f5; }
[data-theme="dark"] .ch-mark.max { color: #a896ff; }

/* телефон: открытый чат — на весь экран, без нижней панели; панель ввода — одна строка крупных иконок */
@media (max-width: 820px) {
  .layout.in-chat { grid-template-rows: 1fr; }
  .layout.in-chat nav.side { display: none; }
  .layout.in-chat .chats { height: 100dvh; }
  .compose { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .compose .tools { flex-wrap: nowrap; gap: 2px; }
  .compose .tools .btn.small { min-width: 44px; height: 44px; padding: 0 10px; }
  .compose .tools .btn.primary { height: 44px; }
  .compose .tools .lbl { display: none; }
  .compose .tools .idle-sm, .compose .tools .busy-sm { display: none; }
  .compose .chip { min-height: 36px; padding: 8px 12px; font-size: 13.5px; display: inline-flex; align-items: center; }
  .page-head .btn-pair { width: 100%; } .page-head .btn-pair .btn { flex: 1; }
  .people-row .acts { width: 100%; justify-content: flex-start; margin-left: 52px; }
}
.compose .tools .lbl { margin-left: 4px; }

/* итерация 2 */
@media (max-width: 1180px) { .conv-head .pill-l { display: none; } }
.who-answers { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-3); padding: 6px 10px; border-radius: 10px; background: var(--panel); }
.who-answers .wa-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-answers .wa-t svg { vertical-align: -3px; margin-right: 4px; }
.who-answers .link-btn { white-space: nowrap; flex-shrink: 0; }
.who-answers b { color: var(--ink-2); }
.who-answers .link-btn { margin-left: auto; }
.compose textarea.note-mode { background: var(--note); border-color: var(--note-line); }
.compose .btn.note-on { background: var(--note); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--note-line); }
.chip.file-chip { display: inline-flex; align-items: center; gap: 6px; }
.chip.file-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.msg .file { max-width: 100%; }
.msg .file .fn { overflow-wrap: anywhere; word-break: normal; min-width: 0; }
.msg .file .fs { color: var(--faint); font-size: 12px; white-space: nowrap; }
.msg .file .fi { flex-shrink: 0; }
.player { display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 320px; padding: 2px 0; }
.player .play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.player .track { flex: 1; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink-3) 22%, transparent); cursor: pointer; position: relative; }
.player .fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--brand); }
.player .t { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.act-sheet { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.act-sheet a.cancel { justify-content: center; color: var(--ink-3); border-top: 1px solid var(--line); border-radius: 0; margin-top: 4px; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
.field .err { font-weight: 500; }
@media (max-width: 820px) {
  .conv-head .btn.icon { min-width: 40px; height: 40px; }
}

/* итерация 3 */
input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
.more-toggle { align-self: flex-start; text-decoration: none; }
.avatar.ch-av { font-size: 10.5px; letter-spacing: .02em; }
.who-wrap { position: relative; }
.who-btn { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.who-btn:hover { background: var(--chip); }
.who-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu.up { top: auto; bottom: calc(100% + 4px); left: 0; right: auto; }
@media (max-width: 1180px) { .menu.up { left: calc(100% + 6px); bottom: 0; } }
@media (max-width: 820px) { nav.side .who-wrap { display: none; } }

/* итерация 4 */
.alert-row.clickable { cursor: pointer; }
.alert-row.clickable:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.alert-row.bad .ic { color: var(--danger-ink); }
.alert-row.warn .ic { color: var(--warn-ink); }
.alert-row.bad { box-shadow: inset 3px 0 0 var(--danger); }
.dep-row.child { padding-left: calc(4px + var(--lvl) * 22px); position: relative; }
.dep-row.child::before { content: ""; position: absolute; left: calc(var(--lvl) * 22px - 10px); top: 0; bottom: 50%; width: 10px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-bottom-left-radius: 6px; }
.people-search { max-width: 240px; flex: 1; }
nav.side .menu a { height: auto; flex-direction: row; justify-content: flex-start; padding: 9px 10px; font-size: 14px; font-weight: 500; gap: 10px; white-space: nowrap; min-width: 0; }
nav.side .menu a .label, nav.side .menu a .short { display: none; }
.profile-menu { min-width: 240px; }
.menu-head { display: flex; flex-direction: column; padding: 6px 10px 4px; }
.show-sm-inline { display: none; }
.an-table { overflow-x: auto; }
@media (max-width: 820px) {
  .an-table table th:first-child, .an-table table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 6px 0 8px -6px rgba(0,0,0,.18); }
  .an-table table th:first-child { background: var(--panel); }
  .show-sm-inline { display: inline-flex; margin-bottom: 12px; }
  .audit-filters { display: none; }
  .audit-filters.open { display: flex; }
  .people-row.dep-row .acts { margin-left: 0; justify-content: flex-start; }
  .people-search { max-width: none; flex-basis: 100%; }
  .acc-table td[data-l] { gap: 4px; }
}
.page > .row[style*="sticky"] { border-top: 1px solid var(--line); box-shadow: 0 -8px 16px -12px rgba(0,0,0,.25); }

/* итерация 5 */
.empty .big.empty-ic { color: var(--faint); display: flex; justify-content: center; }
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.gate-card { max-width: 440px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 28px 24px; box-shadow: var(--shadow); text-align: center; }
.gate-card .brand { justify-content: center; padding: 0 0 18px; }
.gate-card h1 { font-size: 20px; margin: 0 0 10px; }
.gate-card p { margin: 0 0 8px; line-height: 1.5; }
.onboard { max-width: 520px; margin: 0 auto; padding: 48px 28px; }
.onboard h2 { margin: 0 0 8px; font-size: 20px; }
.onboard > p { margin: 0 0 20px; line-height: 1.5; }
.steps-list { list-style: none; counter-reset: st; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.steps-list li { counter-increment: st; position: relative; padding: 14px 16px 14px 56px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.steps-list li::before { content: counter(st); position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft-2); color: var(--brand-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.steps-list li .btn { margin-top: 6px; }

/* итерация 6: доступность */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }
.show-sm-only { display: none; }
@media (max-width: 820px) { .show-sm-only { display: inline-flex; } }
a[role]:focus-visible, .item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
[data-theme="dark"] .msg .meta, [data-theme="dark"] .item .time { color: #a3acbc; }
[data-theme="dark"] .link-btn { color: #8aa0f6; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* низкое окно (масштаб 200%, ноутбук с панелями): переписке — больше места */
@media (max-height: 520px) {
  .compose .chips:first-child, .compose > .chips { max-height: 36px; overflow-x: auto; flex-wrap: nowrap; }
  .who-answers .wa-t { font-size: 12px; }
  .who-answers { padding: 3px 8px; }
  .compose textarea { min-height: 38px; }
  .compose { padding: 6px 10px; gap: 4px; }
  .conv-head { min-height: 48px; padding: 6px 12px; }
}
.msg .meta { color: var(--muted); }
[data-theme="dark"] .msg .meta .read { color: var(--brand-ink); }

/* итерация 7: скорость и сеть */
.player .t, .msg .file .fs { color: var(--muted); }
[data-theme="dark"] .unread-line { color: var(--brand-ink); }
[data-theme="dark"] .avatar { color: #b3c1fa; }
.skel .bar, .item.skel .avatar { display: block; height: 10px; border-radius: 6px; background: var(--chip); }
.item.skel { pointer-events: none; }
.item.skel .avatar { width: 32px; height: 32px; border-radius: 50%; }
.msg.skel { min-width: 180px; width: 46%; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.msg.skel .bar { height: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .skel .bar, .item.skel .avatar, .boot-bar { animation: skel 1.4s ease-in-out infinite; }
}
@keyframes skel { 50% { opacity: .45; } }
.feed-end { text-align: center; padding: 14px; color: var(--muted); font-size: 13px; }
.net-bar { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 16px; background: var(--warn-soft); color: var(--warn-ink); font-size: 13.5px; font-weight: 600; border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.net-bar .btn { margin-left: auto; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 18px; padding: 24px; }
.boot-bar { width: 180px; height: 6px; border-radius: 3px; background: var(--chip); }

/* итерация 8: единый стиль */
h2.sec { margin: 0; }
.search.small input { height: 36px; border-radius: 10px; font-size: 13.5px; padding-left: 34px; }
.search.small::before { left: 11px; width: 14px; height: 14px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
.chip svg, .att-line svg { vertical-align: -2px; }
.att-line { display: flex; gap: 6px; align-items: center; }
.stale-note { margin: 8px 10px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn-ink); font-size: 12.5px; }

/* итерация 9: рабочий день */
.away-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; padding: 7px 10px; border-radius: 10px; background: var(--warn-soft); color: var(--warn-ink); font-size: 13px; font-weight: 600; }
.away-bar .link-btn { margin-left: auto; }
.avatar.away { position: relative; overflow: visible; }
.avatar.away::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--warn); border: 2px solid var(--panel); }
.sort-row { display: flex; gap: 4px; align-items: center; font-size: 12.5px; margin-top: 6px; flex-wrap: wrap; }
.sort-row button { border: 0; background: transparent; padding: 3px 8px; border-radius: 8px; color: var(--ink-3); font-size: 12.5px; cursor: pointer; }
.sort-row button.on { background: var(--chip); color: var(--ink); font-weight: 600; }
.kpi.link { cursor: pointer; }
.kpi.link:hover, .kpi.link:focus-visible { border-color: var(--brand); }
.next-btn { white-space: nowrap; }

/* итерация 10: неудобные данные */
.item .t .grp { color: var(--ink-3); margin-right: 4px; vertical-align: -1px; display: inline-flex; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.filter-chips .chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; cursor: default; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chips .chip button { border: 0; background: transparent; color: inherit; width: 20px; height: 20px; border-radius: 6px; cursor: pointer; flex-shrink: 0; }
.filter-chips .chip button:hover { background: var(--line); }
.next-btn .nb-l { margin-right: 4px; }
@media (max-width: 1180px) { .next-btn .nb-l { display: none; } }
.msg .file .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg .file { min-width: 0; }
.more-files { display: block; margin-top: 4px; }
.msg a { word-break: break-word; overflow-wrap: anywhere; }

/* итерация 11: телефон */
.show-coarse { display: none; }
@media (pointer: coarse) { .show-coarse { display: inline-flex; } }
.msg.act-open { box-shadow: 0 0 0 2px var(--brand); }
@media (max-width: 768px) {
  input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea { font-size: 16px !important; }
}
@media (max-width: 480px) {
  .modal-bg { align-items: flex-end; padding: 0; padding-bottom: var(--kb, 0px); }
  .modal { width: 100%; border-radius: 20px 20px 0 0; max-height: calc(var(--vvh, 100dvh) - 24px); padding: 18px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal .actions { position: sticky; bottom: calc(-12px - env(safe-area-inset-bottom)); background: var(--surface); padding: 10px 0 calc(4px + env(safe-area-inset-bottom)); margin-top: 0; }
}
@media (max-width: 820px) {
  .layout.in-chat .chats { height: var(--vvh, 100dvh); }
}

/* итерация 12: ошибки */
.load-error { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: 10px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger-ink); border: 1px solid var(--danger-line); font-size: 14px; }
.up-chip { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.up-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; width: 20px; height: 20px; border-radius: 6px; }
.pv-ic { display: inline-flex; vertical-align: -2px; margin-right: 4px; color: var(--ink-3); }
