/* Оформление как на сайте nalogychet.ru: navy + золото, Montserrat и Cormorant Garamond.
   Тёмная тема — по настройке устройства. Шрифты свои (OFL, см. fonts/OFL.txt), без Google Fonts. */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/montserrat-400.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/montserrat-400-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; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/montserrat-500.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/montserrat-500-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; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/montserrat-600.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/montserrat-600-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; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/montserrat-700.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/montserrat-700-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; }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/cormorant-garamond-500.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/cormorant-garamond-500-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; }

:root {
  --st-amber-bg: #FDF3DC; --st-amber: #7A5410; --st-red-bg: #FDE8E6; --st-red: #A6342A; --st-green-bg: #E4F4EA; --st-green: #1F6A43; --st-grey-bg: #EDF0F3; --st-grey: #55616E;
  /* палитра сайта */
  --navy: #0E2A47; --navy2: #163E66; --navy3: #254764; --ink: #18324D; --blue-muted: #9BB4CD;
  --beige: #D7D1C8; --beige-light: #E8E2DA; --paper: #F6F2EC; --white: #F8FAFC;
  --gold: #D4A64A; --gold-dark: #B9862C; --on-gold: #102941; --radius: 14px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", "Segoe UI", Arial, sans-serif;
  /* роли (на них опираются все правила ниже) */
  --bg: var(--paper); --surface: #FFFFFF; --surface-2: var(--beige-light); --mine: var(--beige-light);
  --text: var(--ink); --muted: #6E7E8D; --line: rgba(24,50,77,.17);
  --primary: var(--navy); --on-primary: var(--white); --accent: var(--gold); --accent-text: #8A6420; /* мелкий золотой текст: #B9862C на светлом читается плохо */
  --head: var(--navy); --head-text: #C6D5E2; --head-line: rgba(255,255,255,.12);
  --bad: #C8443A; --error-bg: #F7E3E1; --focus: rgba(212,166,74,.55);
  --shadow: 0 1px 2px rgba(24,50,77,.06), 0 6px 18px rgba(24,50,77,.07);
  color-scheme: light;
}
/* Тема: по устройству (по умолчанию) или выбранная вручную — data-theme на <html> (переключатель в шапке). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--navy); --surface: var(--navy2); --surface-2: #0B2239; --mine: var(--navy3);
    --text: var(--white); --muted: var(--blue-muted); --line: rgba(255,255,255,.14);
    --primary: var(--gold); --on-primary: var(--on-gold); --accent-text: var(--gold);
    --head: #0B2239; --head-line: rgba(255,255,255,.1);
    --error-bg: #4A2230; --shadow: 0 1px 2px rgba(0,0,0,.25); color-scheme: dark;
    --st-amber-bg: rgba(212,166,74,.2); --st-amber: #F0CE87; --st-red-bg: rgba(200,68,58,.25); --st-red: #F4A9A1; --st-green-bg: rgba(60,160,105,.25); --st-green: #8FD9B0; --st-grey-bg: rgba(255,255,255,.12); --st-grey: #C6D5E2;
  }
}
:root[data-theme="dark"] {
  --bg: var(--navy); --surface: var(--navy2); --surface-2: #0B2239; --mine: var(--navy3);
  --text: var(--white); --muted: var(--blue-muted); --line: rgba(255,255,255,.14);
  --primary: var(--gold); --on-primary: var(--on-gold); --accent-text: var(--gold);
  --head: #0B2239; --head-line: rgba(255,255,255,.1);
  --error-bg: #4A2230; --shadow: 0 1px 2px rgba(0,0,0,.25); color-scheme: dark;
  --st-amber-bg: rgba(212,166,74,.2); --st-amber: #F0CE87; --st-red-bg: rgba(200,68,58,.25); --st-red: #F4A9A1; --st-green-bg: rgba(60,160,105,.25); --st-green: #8FD9B0; --st-grey-bg: rgba(255,255,255,.12); --st-grey: #C6D5E2;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; line-height: 1.1; }
h1 { font-size: 34px; margin: 0 0 20px; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input, textarea, button, select { font: inherit; }
input, textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }

/* Кнопки — «таблетки», как на сайте: основная navy, акцентная золото, второстепенная контур. */
button { min-height: 40px; padding: 8px 20px; border: 1px solid transparent; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: var(--navy2); }
button:disabled { opacity: .55; cursor: default; }
.btn-gold, button.btn-gold { background: var(--gold); color: var(--on-gold); }
.btn-gold:hover, button.btn-gold:hover { background: #E2B653; }
.btn-outline, button.btn-outline { background: transparent; color: var(--text); border-color: var(--line); }
.btn-outline:hover, button.btn-outline:hover { border-color: var(--gold); background: transparent; }
button.small { min-height: 32px; padding: 4px 14px; border-radius: 999px; background: transparent; color: var(--text); border-color: var(--line); font-size: 13px; font-weight: 600; }
button.small:hover { border-color: var(--gold); background: var(--surface-2); }
button.link { min-height: 0; background: none; border: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; padding: 0; font-weight: 500; border-radius: 0; }
button.link:hover { background: none; color: var(--accent-text); }
button.danger, button.small.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover { background: #A9362E; }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) button:hover { background: #E2B653; }
  :where(:root:not([data-theme="light"])) button.small:hover, :where(:root:not([data-theme="light"])) .btn-outline:hover { background: rgba(255,255,255,.06); }
}
:where(:root[data-theme="dark"]) button:hover { background: #E2B653; }
:where(:root[data-theme="dark"]) button.small:hover, :where(:root[data-theme="dark"]) .btn-outline:hover { background: rgba(255,255,255,.06); }

/* Отдельные страницы (вход, регистрация, сотрудники) — карточка по центру на бумажном фоне. */
.page { max-width: 680px; margin: 8vh auto 32px; padding: 32px 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.page.auth { max-width: 440px; }
.page .brand { display: block; margin: 0 0 18px; font-family: var(--serif); font-size: 26px; font-weight: 500; color: var(--accent-text); text-decoration: none; }
.page > .muted { font-size: 14px; }
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.stack > button { justify-self: start; min-height: 46px; padding: 0 28px; }
.error { background: var(--error-bg); padding: 10px 14px; border-radius: 10px; margin: 8px 16px; }
.muted { color: var(--muted); }
.bad { color: var(--bad); }
.card { background: var(--surface-2); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
/* Настройки: строка с тумблером и список разделов */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row label { font-size: 16px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 28px; margin: 0; border-radius: 999px; background: var(--muted); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch:checked { background: var(--gold); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.set-list { display: flex; flex-direction: column; margin: 16px 0; border-top: 1px solid var(--line); }
.set-list a { display: flex; flex-direction: column; gap: 2px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.set-list a:hover b { color: var(--accent-text); }
.set-list .muted { font-size: 13px; }
.people { width: 100%; border-collapse: collapse; margin: 16px 0 24px; }
.people td { padding: 14px 8px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.people form { display: inline-block; margin: 0 6px 6px 0; }
.people tr:has(+ .pos-row) td { padding-bottom: 6px; border-bottom: 0; }
.people .pos-row td { padding-top: 0; }
.people .pos-form { display: grid; gap: 8px; margin: 0; }
.pos-form .picks { gap: 6px; }
.pos-form button.small { justify-self: start; }
.pos-form .pick { min-height: 34px; padding: 2px 12px 2px 10px; font-size: 13px; }
.pos-title { margin: 32px 0 6px; font-family: var(--serif); font-size: 27px; font-weight: 500; }
.pos-list { margin: 12px 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.pos-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pos-list form { margin: 0; }
.pos-rename { flex: 1 1 280px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.pos-rename input { flex: 1; min-width: 0; }
.pos-new { margin: 12px 0 0; }
@media (max-width: 560px) {
  .page { margin: 0; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; padding: 24px 16px; }
  .people tr:has(+ .pos-row) { padding-bottom: 0; border-bottom: 0; }
  .people .pos-row { padding-top: 6px; }
  .pos-rename { flex-wrap: wrap; }
  .pos-rename input { flex: 1 1 100%; }
  .people tr { display: grid; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .people td { padding: 2px 0; border: 0; }
}

/* Чаты: две колонки на компьютере, одна на телефоне. */
body.app { height: 100dvh; overflow: hidden; }
.layout { display: grid; grid-template-columns: var(--side-w, minmax(280px, 360px)) 1fr; height: 100dvh; }
.side { position: relative; container-type: inline-size; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
/* граница между списком и перепиской — тянется мышью, двойной щелчок возвращает как было */
.splitter { position: absolute; top: 0; right: -5px; z-index: 5; width: 9px; height: 100%; cursor: col-resize; touch-action: none; }
.splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 3px; background: transparent; transition: background .15s; }
.splitter:hover::after, .splitter.drag::after { background: var(--gold); opacity: .7; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }
/* navy-шапка левой колонки: слово-логотип, ссылки, разделы */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; padding-top: max(14px, env(safe-area-inset-top)); background: var(--head); color: #fff; }
.top h1 { margin: 0; font-size: 27px; color: #fff; white-space: nowrap; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--head-text); }
.top nav a { text-decoration: none; }
.top nav a:hover, .top nav button.link:hover { color: var(--gold); }
.top nav button.link { text-decoration: none; color: var(--head-text); }
/* шестерёнка «Настройки» — справа в navy-шапке */
.top nav .gear { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: var(--head-text); }
.top nav .gear:hover, .top nav .gear:focus-visible { color: var(--gold); background: rgba(255,255,255,.08); }
.top nav form { margin: 0; }
.push-note { margin: 0; padding: 0 16px 8px; background: var(--head); color: var(--head-text); font-size: 13px; }
.sections { display: flex; gap: 4px; padding: 0 8px; background: var(--head); border-bottom: 1px solid var(--head-line); }
.sections button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; min-height: 44px; padding: 8px 2px; background: transparent; color: var(--head-text); border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 14px; font-weight: 600; }
.sections button:hover { background: transparent; color: #fff; }
.sections button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.sections .count { margin-left: 0; }
/* узкая левая колонка (например, в почте) — всё помещается без обрезки */
@container (max-width: 330px) {
  .top h1 { font-size: 23px; }
  .top nav { gap: 10px; }
  .sections button { font-size: 13px; }
}
/* вкладки внутри раздела — подчёркивание золотом */
.tabs { display: flex; gap: 4px; padding: 6px 12px 0; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; min-height: 38px; padding: 6px 2px; font-size: 13px; font-weight: 600; background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }
#q { margin: 0 12px 10px; width: auto; border-radius: 999px; padding: 9px 16px; background: var(--bg); }
.list { flex: 1; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
.list-empty { padding: 0 16px; }
.row { padding: 11px 16px 11px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--bg); }
.row.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--gold); }
.row-top, .row-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-title, .row-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { font-weight: 600; }
.row-preview { font-size: 14px; }
.row-at { font-size: 12px; }
.badge { padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 700; color: #fff; }
.badge.tg { background: #2AABEE; }
.badge.max { background: #7B4DFF; }
.wait { font-size: 12px; font-weight: 600; color: var(--bad); white-space: nowrap; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--on-gold); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.count[hidden] { display: none; }
.pane, .pane-empty { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.pane-empty { align-items: center; justify-content: center; }
.pane-empty p { font-family: var(--serif); font-size: 24px; }
.pane[hidden], .pane-empty[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head > div { flex: 1; min-width: 0; }
.chat-head h2 { margin: 0; font-size: 25px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .muted { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* шапка справа — такая же navy, как слева, той же высоты (--head-h ставит app.js), с тонкой линией между ними */
.layout .chat-head { min-height: var(--head-h, 64px); background: var(--head); color: #fff; border-bottom: 1px solid var(--head-line); box-shadow: inset 1px 0 0 rgba(255,255,255,.16); }
.chat-head h2 { color: #fff; }
.chat-head .muted { color: var(--head-text); }
.chat-head button.small { border-color: rgba(255,255,255,.28); color: var(--head-text); }
.chat-head button.small:hover { border-color: var(--gold); background: transparent; color: #fff; }
.chat-head button.small.bind-btn { border-color: var(--gold); color: var(--gold); }
.chat-head .info-btn { color: var(--gold); }
.chat-head .find-btn { color: #fff; }
.chat-head .info-btn:hover, .chat-head .info-btn:focus-visible, .chat-head .find-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.back { display: none; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 20px 16px; overflow-y: auto; }
.msg { max-width: min(600px, 85%); padding: 10px 14px; border-radius: var(--radius); border-top-left-radius: 4px; background: var(--surface); box-shadow: var(--shadow); }
.msg.mine { align-self: flex-end; background: var(--mine); border-top-left-radius: var(--radius); border-top-right-radius: 4px; box-shadow: none; }
.msg.failed { outline: 2px solid var(--bad); }
.who { font-size: 12px; font-weight: 700; color: var(--accent-text); }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.kind { font-size: 14px; color: var(--muted); }
.meta { font-size: 11px; color: var(--muted); text-align: right; }
.err { font-size: 12px; color: var(--bad); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .splitter { display: none; }
  body.chat-open .side, body.chat-open .pane-empty { display: none; }
  body:not(.chat-open) .pane, body:not(.chat-open) .pane-empty { display: none; }
  .back { display: inline-block; }
  .top h1 { font-size: 25px; }
  .chat-head { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .layout .chat-head { min-height: 64px; box-shadow: none; }   /* на телефоне колонки по очереди — равнять не с чем */
  .chat-head h2 { font-size: 22px; }
  input, textarea, select, .mc-body { font-size: 16px; } /* iPhone не увеличивает страницу при вводе */
  .msg { max-width: 90%; }
}
.stack label.show-pw { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.show-pw input { width: auto; accent-color: var(--gold); }
/* Вложения и лоток. */
button.icon { min-height: 0; padding: 6px 8px; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 10px; font-size: 17px; font-weight: 400; line-height: 1; }
button.icon:hover { background: var(--surface-2); }
.tray[hidden], .upload[hidden] { display: none; }
.chip { display: flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.upload { margin: 0; padding: 4px 16px; background: var(--surface); font-size: 13px; }
.file { display: grid; gap: 4px; margin: 4px 0; justify-items: start; }
.thumb { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; }
.file audio { width: 260px; max-width: 100%; }
.file-link { font-size: 14px; overflow-wrap: anywhere; }
.pane.drop { outline: 3px dashed var(--gold); outline-offset: -6px; }
/* Действия с сообщением, правка, смайлы, реакции. */
.msg { position: relative; }
.msg .more { position: absolute; top: 2px; right: 4px; min-height: 0; padding: 0 6px; background: transparent; color: var(--muted); border: 0; font-size: 18px; line-height: 1; visibility: hidden; }
.msg:hover .more, .msg.open .more { visibility: visible; }
@media (pointer: coarse) { .msg .more { display: none; } }
.actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.actions .ask { font-size: 13px; font-weight: 600; margin-right: 4px; }
button.react { min-height: 0; padding: 2px 8px; background: transparent; border: 1px solid var(--line); color: var(--text); font-size: 18px; font-weight: 400; line-height: 1.2; }
button.react.on { border-color: var(--gold); background: var(--surface-2); }
.reaction { font-size: 13px; color: var(--muted); margin-top: 2px; }
.body.deleted { font-style: italic; color: var(--muted); }
.editbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0; padding: 6px 16px; background: var(--surface-2); font-size: 13px; }
.editbar[hidden], .emoji-panel[hidden] { display: none; }
.emoji-panel { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--line); }
button.emo { min-height: 0; padding: 4px; background: transparent; border-radius: 8px; font-size: 20px; font-weight: 400; line-height: 1; color: var(--text); }
button.emo:hover { background: var(--surface-2); }
/* Поле сообщения — одна рамка, как в Telegram: миниатюры вложений сверху, под ними скрепка, текст, смайлы. */
.box { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--bg); }
.box:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }
.box .tray { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 12px 0; }
.box .line { display: flex; align-items: flex-end; gap: 2px; padding: 2px 6px; }
.box textarea { flex: 1; min-height: 40px; line-height: 22px; max-height: 40vh; resize: none; border: 0; background: transparent; padding: 9px 6px; outline: none; box-shadow: none; }
.box button.icon { border: 0; padding: 8px 6px; font-size: 20px; background: transparent; }
.box textarea::placeholder { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbwrap { position: relative; }
.thumbwrap img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
button.x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; font-weight: 400; line-height: 22px; }
.chip button.x { position: static; flex: none; }
#send { min-height: 44px; }
.tabs[hidden], #q[hidden] { display: none; }
.badge.staff { background: transparent; font-size: 14px; padding: 0; }

/* Поиск. */
mark { background: #F3DCA2; color: inherit; border-radius: 2px; padding: 0 1px; }
.msg.current { outline: 2px solid var(--gold); }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px #F3DCA2; } to { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) { .msg.flash { animation: none; } }
.find-btn { margin-left: auto; min-height: 0; padding: 6px 8px; background: transparent; color: var(--text); border: 0; font-size: 18px; font-weight: 400; }
.find-btn:hover { background: var(--surface-2); }
.findbar { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.findbar[hidden], .found[hidden] { display: none; }
.findbar input { flex: 1; min-width: 0; border-radius: 999px; padding: 7px 14px; }
#find-count { font-size: 13px; white-space: nowrap; }
.found-title { margin: 8px 16px 4px; font-size: 13px; font-weight: 600; }
.to-latest { align-self: center; margin: -48px auto 8px; position: relative; z-index: 2; padding: 6px 16px; box-shadow: var(--shadow); }
.to-latest[hidden] { display: none; }
.file video.video { display: block; max-width: min(100%, 480px); max-height: 60vh; border-radius: 10px; background: #000; margin-bottom: 4px; }

/* Почта. */
.side-part { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.side-part[hidden] { display: none; }
/* почта как в Mail.ru: слева папки, справа широкий список; письмо — на месте списка */
.mail-tools select { flex: 1; min-width: 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; }
.mail-new { margin: 12px 12px 10px; min-height: 44px; background: var(--gold); color: var(--on-gold); }
.mail-new:hover { background: #E2B653; }
.mail-folders { flex: 1; margin: 0; padding: 0 8px 12px; list-style: none; overflow-y: auto; }
.mail-folder { display: flex; align-items: center; gap: 6px; min-height: 38px; padding-right: 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.mail-folder:hover { background: var(--bg); }
.mail-folder.active { background: var(--surface-2); font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.mf-twist { width: 18px; min-height: 0; flex: none; padding: 0; background: transparent; color: var(--muted); border: 0; font-size: 15px; font-weight: 400; line-height: 1; }
.mf-twist:hover { background: transparent; color: var(--text); }
.mf-icon { flex: none; width: 20px; text-align: center; font-size: 15px; }
.mf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-count { flex: none; color: var(--muted); font-size: 13px; }
.mail-listview { flex: 1; min-height: 0; overflow-y: auto; background: var(--surface); }
.mail-listview[hidden], .mail-note[hidden], #mail-read-all[hidden] { display: none; }
.mail-listbar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.mail-listbar input[type=search] { flex: 1 1 220px; min-width: 0; border-radius: 999px; padding: 8px 16px; background: var(--bg); }
.mail-all { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.mail-all input { width: auto; accent-color: var(--gold); }
.mail-note { margin: 8px 16px 0; font-size: 13px; }
.mail-list { margin: 0; padding: 0 0 8px; list-style: none; }
.mail-group { padding: 16px 16px 4px 44px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mail-row { display: grid; grid-template-columns: 12px 32px minmax(120px, 220px) 1fr auto; align-items: center; gap: 10px; min-height: 54px; padding: 0 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mail-row:hover { background: var(--bg); }
.mail-row.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--gold); }
.mail-dot { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
.mail-row.unread .mail-dot { background: var(--gold); }
.mail-ava { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-size: 14px; font-weight: 600; }
.mail-who, .mail-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-who { font-size: 15px; }
.mail-subject { font-size: 15px; }
.mail-snippet { margin-left: 10px; color: var(--muted); font-size: 14px; }
.mail-row.unread .mail-who, .mail-row.unread .mail-subject { font-weight: 700; }
.mail-tail { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.mail-in { padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.mail-status { margin-left: 10px; font-size: 13px; }
.mail-status.bad { color: var(--bad); }
.mail-out button.small { grid-column: 3 / -1; justify-self: start; margin-bottom: 8px; }
#mail-back.on { display: inline-block; }
@media (max-width: 760px) {
  .mail-row { grid-template-columns: 8px 36px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 0; padding: 8px 12px; }
  .mail-dot { grid-row: 1 / 3; }
  .mail-ava { grid-row: 1 / 3; width: 36px; height: 36px; }
  .mail-who { grid-column: 3; grid-row: 1; }
  .mail-tail { grid-column: 4; grid-row: 1; }
  .mail-text { grid-column: 3 / 5; grid-row: 2; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 14px; }
  .mail-subject { font-size: 14px; }
  .mail-snippet { margin-left: 6px; font-size: 13px; }
  .mail-group { padding-left: 12px; }
  .mail-listbar { padding: 8px 12px; }
}
.mail-more { margin: 8px auto; }
.mail-more[hidden], .mail-banner[hidden], .mail-images[hidden] { display: none; }
.mail-more { display: block; }
.mail-banner { margin: 12px 12px 0; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.mail-banner.bad { background: #FFF1C2; color: #5A4500; }
.mail-view, .mail-compose { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; background: var(--surface); }
.mail-view[hidden], .mail-compose[hidden] { display: none; }
.mail-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.mail-tools select { flex: 0 1 auto; font-size: 13px; padding: 4px 12px; }
.mail-line { margin: 2px 0; font-size: 14px; overflow-wrap: anywhere; }
.mail-atts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mail-atts a.chip { text-decoration: none; color: inherit; }
.mail-images { font-size: 13px; margin: 6px 0; }
.mail-frame { display: block; width: 100%; min-height: 200px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.mc-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.mc-row[hidden], .mc-suggest[hidden] { display: none; }
.mc-links { display: flex; gap: 12px; margin: -2px 0 8px 78px; font-size: 13px; }
.mc-suggest { list-style: none; margin: -4px 0 8px 78px; padding: 4px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.mc-suggest li { padding: 6px 12px; cursor: pointer; font-size: 14px; }
.mc-suggest li:hover { background: var(--surface-2); }
.mc-format { display: flex; gap: 4px; margin: 8px 0; }
.mc-body { min-height: 240px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; overflow-wrap: anywhere; }
.mc-body:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }
.mc-body blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--line); padding-left: 1ex; }
.mc-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mc-status { font-size: 13px; min-height: 1.2em; }
.mc-actions { display: flex; justify-content: space-between; gap: 8px; }
.mail-compose.drop { outline: 3px dashed var(--gold); outline-offset: -6px; }
@media (max-width: 760px) {
  .mc-row { grid-template-columns: 1fr; gap: 2px; }
  .mc-links, .mc-suggest { margin-left: 0; }
}

/* ответы и отметки прочтения */
.quote { border-left: 3px solid var(--gold); background: var(--surface-2); padding: 3px 8px; margin: 2px 0 4px;
  border-radius: 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.mine .quote { background: var(--surface); }
.quote.link { cursor: pointer; }
.replybar .quote { flex: 1; min-width: 0; margin: 0; }
.tick.read { color: var(--primary); }
.seen { flex-basis: 100%; font-size: 12px; color: var(--muted); }

/* Клиенты: пометки в списке групп. */
.row-client { margin: 1px 0 2px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unbound { display: inline-block; padding: 0 8px; border-radius: 999px; background: rgba(212,166,74,.18); color: var(--accent-text); font-size: 12px; font-weight: 600; line-height: 20px; }
.row-bday { margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-note { margin: 0 12px 10px; padding: 8px 14px; border-radius: 10px; background: var(--error-bg); font-size: 14px; }
.list-note[hidden] { display: none; }

/* Шапка переписки: ⓘ и «Привязать к клиенту». */
.info-btn { min-height: 0; padding: 4px 9px; background: transparent; color: var(--accent-text); border: 0; border-radius: 999px; font-size: 21px; font-weight: 400; line-height: 1; }
.info-btn:hover, .info-btn:focus-visible { background: var(--surface-2); color: var(--text); }
button.small.bind-btn { flex: none; border-color: var(--gold); color: var(--accent-text); }
button.small.bind-btn:hover { background: rgba(212,166,74,.14); color: var(--text); }
.info-btn[hidden], .bind-btn[hidden] { display: none; }
.group-also { display: block; font-size: 12px; }

/* Карточка клиента: на компьютере — на месте переписки, на телефоне — отдельный экран. */
.card-pane[hidden] { display: none; }
.card-top { min-height: 52px; background: var(--head); border-bottom: 0; }
button.small.card-back { border-color: rgba(255,255,255,.28); color: var(--head-text); }
button.small.card-back:hover { border-color: var(--gold); background: transparent; color: #fff; }
/* «Предыдущий / Следующий» — когда карточку открыли из «Настройки → Клиенты» */
.card-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-nav[hidden] { display: none; }
.card-pos { font-size: 13px; color: var(--head-text); white-space: nowrap; }
@media (max-width: 480px) { .card-nav .nav-word { display: none; } }
.card-body { flex: 1; min-height: 0; overflow-y: auto; outline: none; }
.card-loading { padding: 24px; }
.card-wrap { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
.card-wrap > *:not(.card-hero) { max-width: 920px; }
/* главное в карточке — navy-полоса с названием, как первый экран сайта */
.card-hero { padding: 6px 28px 28px; background: var(--head); color: #fff; border-bottom: 3px solid var(--gold); }
.hero-line { display: flex; align-items: flex-start; gap: 16px; }
.card-name { flex: 1; min-width: 0; margin: 0 0 14px; font-size: 44px; line-height: 1.05; color: #fff; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.card-hero .fact { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 14px; border: 1px solid rgba(212,166,74,.55); border-radius: 999px; color: #fff; font-size: 14px; text-decoration: none; }
.card-hero a.fact:hover { background: rgba(212,166,74,.16); border-color: var(--gold); }
.card-hero .fact.plain { border-color: rgba(255,255,255,.2); color: var(--head-text); }
button.small.on-navy { flex: none; margin-top: 10px; border-color: rgba(255,255,255,.28); color: var(--head-text); }
button.small.on-navy:hover { border-color: var(--gold); background: transparent; color: #fff; }
.hero-acts { margin-top: 4px; }
/* «Ссылка на бота»: выбор контакта и готовая ссылка */
.bot-link-dialog .fld { display: grid; gap: 6px; margin: 0 0 16px; font-size: 14px; }
.bot-link-dialog select { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.bot-link-dialog .error { margin: 0 0 12px; }
.bot-link-dialog .error[hidden] { display: none; }
.link-box { margin-top: 14px; font-family: ui-monospace, Consolas, monospace; background: var(--bg); }  /* размер шрифта — общий: на телефоне 16px, без увеличения страницы */
.bot-link-dialog .dlg-hint { margin: 8px 2px 18px; }
.bot-link-dialog .dlg-acts { flex-wrap: wrap; }
.card-sec { padding: 22px 28px 4px; }
.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sec-head h3 { flex: 1; display: flex; align-items: baseline; gap: 10px; margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 500; line-height: 1.1; }
.sec-count { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); }
.sec-note { font-size: 13px; }
.sec-empty, .sec-hint { margin: 0 0 8px; font-size: 14px; }
.sec-hint { margin-top: 10px; }
/* люди — единственное, что оформлено плитками: у каждого свой набор сведений */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 12px; }
.person { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person.soon { border-color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }
.person.editing { grid-column: 1 / -1; border-color: var(--gold); }
.person h4 { margin: 0 0 10px; font-family: var(--serif); font-size: 22px; font-weight: 500; }
.person-head { display: flex; align-items: flex-start; gap: 12px; }
.ava { flex: none; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--gold); font-family: var(--serif); font-size: 19px; font-weight: 500; }
.person-who { flex: 1; min-width: 0; display: grid; }
.person-name { font-weight: 600; overflow-wrap: break-word; }
.person-pos { font-size: 13px; }
/* Обособленные подразделения: строка «название · адрес · КПП» и кнопка справа. */
.branch-list { display: grid; gap: 8px; }
.branch { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.branch-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 14px; overflow-wrap: break-word; }
.branch-name { font-weight: 600; }
.branch-kpp { font-size: 13px; }
.branch.editing { display: block; border-color: var(--gold); }
.branch h4 { margin: 0 0 10px; font-family: var(--serif); font-size: 22px; font-weight: 500; }
@media (max-width: 560px) {               /* длинный заголовок — на всю строку, кнопка под ним */
  .branches-sec .sec-head { flex-wrap: wrap; }
  .branches-sec .sec-head h3 { flex-basis: 100%; display: block; }      /* число — сразу за текстом, а не у края */
  .branches-sec .sec-head .sec-count { margin-left: 8px; }
}
.bday-soon { display: inline-block; margin: 10px 0 0; padding: 2px 10px; border-radius: 999px; background: rgba(212,166,74,.18); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.person-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: 14px; }
.person-facts dt { color: var(--muted); }
.person-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.person-facts .fact { color: var(--text); }
.groups { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.group { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
button.group-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 4px; background: transparent; color: var(--text); border: 0; border-radius: 0; font-weight: 600; text-align: left; }
button.group-open:hover { background: transparent; color: var(--accent-text); }
.group-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-off { font-size: 13px; font-weight: 500; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 16px 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; }
.pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }
.pick:has(input:checked) { border-color: var(--gold); background: rgba(212,166,74,.14); }
.pick:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
/* ведут клиента — строка на должность: название слева, плашки людей справа */
.staff-rows { border-top: 1px solid var(--line); }
.staff-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 6px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.staff-pos { font-size: 14px; font-weight: 600; }
.staff-people { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.staff-none { font-size: 14px; }
.staff-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 34px; padding: 2px 2px 2px 14px; border: 1px solid var(--gold); border-radius: 999px; background: rgba(212,166,74,.14); font-size: 14px; font-weight: 500; }
.staff-chip.off { border-style: dashed; border-color: var(--line); background: transparent; }
.staff-name { overflow-wrap: anywhere; }
.staff-note { font-size: 12px; color: var(--bad); }
button.staff-x { flex: none; width: 30px; height: 30px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 19px; font-weight: 400; line-height: 1; }
button.staff-x:hover { background: var(--surface-2); color: var(--bad); }
button.small.staff-add { min-height: 34px; border-style: dashed; color: var(--accent-text); }
.staff-opts, .staff-hint { grid-column: 2; }
.staff-opts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.staff-hint { margin: 0; font-size: 13px; }
@media (max-width: 560px) {
  .staff-row { grid-template-columns: 1fr; }
  .staff-opts, .staff-hint { grid-column: 1; }
  button.staff-x { width: 36px; height: 36px; }
}
.comment { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.card-foot { padding: 28px 28px 8px; }
button.small.danger-outline { border-color: rgba(200,68,58,.45); color: var(--bad); }
button.small.danger-outline:hover { background: var(--error-bg); border-color: var(--bad); color: var(--bad); }
/* формы правки — на месте блока */
.edit .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 14px; }
.fld { display: grid; gap: 4px; align-content: start; font-size: 13px; font-weight: 600; }
.fld.wide { grid-column: 1 / -1; }
.fld small { font-size: 12px; font-weight: 500; }
.edit textarea { resize: vertical; }
.edit select { min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.bday-line { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px; }
.form-error { margin: 12px 0 0; }
.form-error[hidden] { display: none; }
.form-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.form-acts .push-right { margin-left: auto; }
.edit.on-hero { padding-top: 16px; }
.edit.on-hero .fld { color: var(--head-text); }
.edit.on-hero button.small { border-color: rgba(255,255,255,.28); color: var(--head-text); }
.edit.on-hero button.small:hover { border-color: var(--gold); background: transparent; color: #fff; }
button.btn-gold:hover { background: #E2B653; color: var(--on-gold); }
.fld[hidden] { display: none; }
.form-sub { margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-family: var(--serif); font-size: 21px; font-weight: 500; }
.edit.on-hero .form-error { color: var(--text); }   /* на navy-полосе текст белый — у плашки ошибки свой */
.edit.on-hero .form-sub { border-top-color: var(--head-line); color: #fff; }
.inn-line { display: flex; gap: 8px; align-items: center; min-width: 0; }
.inn-line input { flex: 1; min-width: 0; }
.inn-line button.small { flex: none; min-height: 42px; }
.fld.chk { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 42px; font-size: 14px; cursor: pointer; }
.fld.chk input, .dlg-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); }
.check-boxes { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.check-item { display: flex; align-items: center; gap: 10px; min-height: 42px; font-size: 14px; cursor: pointer; }
.check-item input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); }

/* Реквизиты: подпись слева, значение справа; на телефоне — подпись над значением. */
.req-facts { display: grid; grid-template-columns: minmax(130px, 190px) 1fr; gap: 6px 16px; margin: 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; }
.req-facts dt { color: var(--muted); }
.req-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.req-post { display: block; font-size: 13px; }
.req-code { font-weight: 600; }
.req-meta { margin: 8px 0 0; font-size: 12px; }
.status-bad { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--error-bg); color: var(--bad); font-weight: 600; }
.hist { margin-top: 10px; }
button.link.hist-toggle { font-size: 14px; font-weight: 600; text-decoration: none; color: var(--accent-text); }
button.link.hist-toggle:hover { text-decoration: underline; }
.hist-list { margin: 10px 0 0; padding: 0; list-style: none; border-left: 2px solid var(--gold); }
.hist-item { padding: 6px 0 8px 14px; }
.hist-head { margin: 0; font-size: 13px; font-weight: 600; }
.hist-lines { margin: 2px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tax-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tax-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 3px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 500; }
/* окно «Заполнить по ИНН» и новый клиент в окне привязки */
.dlg-found { margin: -8px 0 12px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.dlg-status { margin: 0 0 12px; }
.dlg-check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.dlg-rename { margin: 4px 0 16px 30px; font-size: 14px; overflow-wrap: anywhere; }
.dlg-inn-note:empty { display: none; }
.dlg-inn-note .error { margin: 0; }
.dlg-ask { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; overflow-wrap: anywhere; }
.dlg-ask p { margin: 0 0 8px; }
.dlg-ask .dlg-acts { flex-wrap: wrap; }
@media (max-width: 560px) {
  .req-facts { grid-template-columns: 1fr; gap: 0; }
  .req-facts dt { margin-top: 6px; font-size: 12px; }
  .req-facts dt:first-child { margin-top: 0; }
}

/* Окно поверх (подтверждение, привязка). На телефоне привязка — на весь экран. */
.kc-dialog { width: min(520px, calc(100vw - 32px)); max-height: min(640px, calc(100dvh - 32px)); padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(14,42,71,.35); }
.kc-dialog::backdrop { background: rgba(14,42,71,.55); }
.small-dialog { padding: 22px 24px 18px; width: min(440px, calc(100vw - 32px)); }
.dlg-title { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500; line-height: 1.15; }
.dlg-text { margin: 10px 0 20px; font-size: 15px; }
.dlg-acts { display: flex; justify-content: flex-end; gap: 8px; }
.bind-dialog[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; padding-top: max(18px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.dlg-head > div { flex: 1; min-width: 0; }
.dlg-sub { margin: 4px 0 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-note { margin: 6px 0 0; font-size: 13px; }
button.x-btn { flex: none; width: 40px; height: 40px; min-height: 0; padding: 0; background: transparent; color: var(--muted); border: 0; font-size: 26px; font-weight: 400; line-height: 1; }
button.x-btn:hover { background: var(--surface-2); color: var(--text); }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 20px 20px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.dlg-body .error { margin: 12px 0 0; }
.dlg-body .error[hidden] { display: none; }
.dlg-search { border-radius: 999px; padding: 10px 18px; background: var(--bg); }
.dlg-hint { margin: 10px 4px; font-size: 14px; }
.dlg-hint[hidden] { display: none; }
.found-clients { margin: 8px 0 0; padding: 0; list-style: none; }
button.client-pick { display: grid; justify-items: start; width: 100%; min-height: 52px; padding: 8px 12px; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); border-radius: 10px; text-align: left; font-weight: 500; }
button.client-pick:hover, button.client-pick:focus-visible { background: var(--surface-2); }
button.client-pick span { font-size: 13px; }
.dlg-new { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.dlg-or { margin: 0; font-size: 14px; font-weight: 600; }
.dlg-new .btn-gold { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .card-hero { padding: 4px 16px 22px; }
  .card-name { font-size: 34px; }
  .card-sec { padding: 20px 16px 4px; }
  .card-foot { padding: 24px 16px 8px; }
  .people-grid { grid-template-columns: 1fr; }
  .bday-line { grid-template-columns: 80px 1fr; }
  .bday-line input { grid-column: 1 / -1; }
  .bind-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .dlg-new .btn-gold { justify-self: stretch; white-space: normal; }
  /* телефон: «Привязать к клиенту» — второй строкой шапки, чтобы название группы не пропадало */
  .chat-head:has(#bind:not([hidden]):not(.more)) { flex-wrap: wrap; row-gap: 6px; }
  .chat-head .bind-btn.more { display: none; }   /* «+ Клиент» на телефоне не теснит название — добавляют с компьютера */
  .chat-head .bind-btn { order: 10; }
}
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) .unbound, :where(:root:not([data-theme="light"])) .bday-soon { background: rgba(212,166,74,.16); }
  :where(:root:not([data-theme="light"])) .ava { background: var(--navy3); }
  :where(:root:not([data-theme="light"])) .pick input { accent-color: var(--gold); }
  :where(:root:not([data-theme="light"])) button.group-open:hover, :where(:root:not([data-theme="light"])) button.client-pick:hover { color: var(--gold); background: transparent; }
  :where(:root:not([data-theme="light"])) button.client-pick:hover { background: rgba(255,255,255,.06); }
  :where(:root:not([data-theme="light"])) .info-btn:hover, :where(:root:not([data-theme="light"])) button.x-btn:hover { background: rgba(255,255,255,.06); }
  :where(:root:not([data-theme="light"])) .kc-dialog::backdrop { background: rgba(0,0,0,.6); }
}
:where(:root[data-theme="dark"]) .unbound, :where(:root[data-theme="dark"]) .bday-soon { background: rgba(212,166,74,.16); }
:where(:root[data-theme="dark"]) .ava { background: var(--navy3); }
:where(:root[data-theme="dark"]) .pick input { accent-color: var(--gold); }
:where(:root[data-theme="dark"]) button.group-open:hover, :where(:root[data-theme="dark"]) button.client-pick:hover { color: var(--gold); background: transparent; }
:where(:root[data-theme="dark"]) button.client-pick:hover { background: rgba(255,255,255,.06); }
:where(:root[data-theme="dark"]) .info-btn:hover, :where(:root[data-theme="dark"]) button.x-btn:hover { background: rgba(255,255,255,.06); }
:where(:root[data-theme="dark"]) .kc-dialog::backdrop { background: rgba(0,0,0,.6); }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) .status-bad { color: #F4A9A1; }
  :where(:root:not([data-theme="light"])) .tax-chip { background: transparent; }
}
:where(:root[data-theme="dark"]) .status-bad { color: #F4A9A1; }
:where(:root[data-theme="dark"]) .tax-chip { background: transparent; }

/* Рабочий телефон: пометки «личка»/«бот»/«новый», вид «По клиентам», шапка личной переписки, окно 24 часов. */
.badge.line { background: var(--gold); color: var(--on-gold); }
.badge.bot { background: #5A6B7D; }
.row-of { font-weight: 500; color: var(--muted); }
.row-bday-in { font-weight: 600; color: var(--accent-text); }   /* коллега: «🎂 завтра» сразу после имени */
.row-new { flex: none; padding: 0 8px; border-radius: 999px; background: rgba(212,166,74,.18); color: var(--accent-text); font-size: 11px; font-weight: 700; line-height: 18px; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; padding: 6px 6px; }
.tabs button[hidden], .sections button[hidden] { display: none; }
/* пять вкладок (с «Личные» и «Новые») — плотнее, чтобы влезли в колонку 360 px и в телефон 390 px */
.tabs:has(> [data-tab="new"]:not([hidden])):has(> [data-tab="personal"]:not([hidden])) { gap: 0; padding: 6px 6px 0; }
.tabs:has(> [data-tab="new"]:not([hidden])):has(> [data-tab="personal"]:not([hidden])) button { padding: 6px 4px; font-size: 12px; }
.group-head { position: sticky; top: 0; z-index: 1; padding: 12px 16px 4px; background: var(--surface); border-bottom: 1px solid var(--line); }
.group-head-name, button.group-head-btn { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--accent-text); }
button.group-head-btn { min-height: 0; padding: 0; background: transparent; border: 0; border-radius: 0; text-align: left; }
button.group-head-btn:hover { background: transparent; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.row.sub { padding-left: 28px; }
.reply-hint { margin: 0; padding: 8px 16px; background: rgba(212,166,74,.16); color: var(--text); font-size: 13px; border-top: 1px solid var(--line); }
.reply-hint[hidden], .head-act[hidden] { display: none; }
.chat-head button.small.head-act { flex: none; }
@media (max-width: 760px) {
  /* телефон: «Скрыть», «Показать», «Загрузить историю» — второй строкой шапки, вместе с «Привязать» */
  .chat-head:has(.head-act:not([hidden])) { flex-wrap: wrap; row-gap: 6px; }
  .chat-head .head-act { order: 11; }
  .chat-head:has(.head-act:not([hidden]))::after { content: ""; order: 9; flex-basis: 100%; height: 0; }   /* перенос строки: название не сжимается */
  .sections:has(> [data-section="personal"]:not([hidden])) button { font-size: 13px; gap: 2px; }
  .row.sub { padding-left: 24px; }
}
/* Настройки: вид списка */
.view-pick { border: 0; display: grid; gap: 6px; }
.view-pick legend { float: left; width: 100%; margin: 0 0 2px; padding: 0; font-size: 16px; font-weight: 600; }
.view-pick > p.muted { margin: 0 0 6px; font-size: 13px; }
.view-opt { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; }
.view-opt:has(input:checked) { border-color: var(--gold); background: var(--surface); }
.view-opt input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--navy); }
.view-opt > span { display: grid; gap: 1px; }
.view-opt .muted { font-size: 13px; }
.view-status { margin: 2px 0 0; min-height: 1.2em; font-size: 13px; }
/* Образец вида списка: показан только выбранный. */
.pv-cap { margin: 4px 0 6px; font-size: 13px; color: var(--muted); }
.pv-box { display: none; max-width: 340px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 13px; }
.view-pick:has(input[value="all"]:checked) .pv-all,
.view-pick:has(input[value="split"]:checked) .pv-split,
.view-pick:has(input[value="clients"]:checked) .pv-clients { display: grid; gap: 4px; }
.pv-tabs { display: flex; gap: 6px; margin-bottom: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 12px; }
.pv-tabs > * { padding: 2px 10px; border-radius: 999px; }
.pv-tabs b { background: var(--navy); color: #fff; }
.pv-tabs span { color: var(--muted); }
.pv-row { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; background: var(--surface-2); white-space: nowrap; overflow: hidden; }
.pv-row i { flex: none; padding: 0 5px; border-radius: 5px; font-style: normal; font-size: 10px; font-weight: 700; color: #fff; }
.pv-tg { background: #2AABEE; }
.pv-max { background: #7B5CFF; }
.pv-row em { margin-left: auto; padding: 0 6px; border: 1px solid var(--gold); border-radius: 999px; font-style: normal; font-size: 10px; color: var(--muted); }
.pv-client { margin-top: 4px; font-weight: 700; }
.pv-client.pv-none { color: var(--muted); font-weight: 600; }
.pv-in { margin-left: 14px; }
.pv-note { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
/* «Рабочий телефон» */
.ph-sec { padding: 18px 0; border-top: 1px solid var(--line); }
.ph-title { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 27px; }
.ph-title .badge { font-family: var(--sans); font-size: 11px; }
.ph-state { margin: 0 0 6px; font-weight: 600; }
.ph-hint { margin: 0 0 10px; font-size: 13px; }
.ph-lines { display: grid; gap: 6px; margin: 0 0 10px; }
.ph-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.ph-line-text { min-width: 0; overflow-wrap: anywhere; }
.ph-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.ph-form { display: grid; gap: 10px; margin-top: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.ph-form[hidden], .ph-step[hidden] { display: none; }
.ph-step { display: grid; gap: 6px; }
.ph-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-inline input { flex: 1 1 200px; min-width: 0; }
.ph-again { justify-self: start; font-size: 13px; }
.ph-form > button.small { justify-self: start; }
.ph-note { margin: 0; min-height: 1.2em; font-size: 13px; }
.ph-note.bad, .ph-state.bad, .ph-line-text.bad, .view-status.bad { color: var(--bad); }
.ph-people { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; padding: 0; list-style: none; }
.ph-hidden { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.ph-hidden:empty { border-top: 0; }
.ph-hid { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ph-hid-who { flex: 1 1 200px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ph-hid-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-hid-at { font-size: 13px; }
.phone-page .error[hidden] { display: none; }
.phone-page .error { margin: 8px 0; }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) .view-opt input { accent-color: var(--gold); }
  :where(:root:not([data-theme="light"])) .badge.bot { background: #6B7F94; }
}
:where(:root[data-theme="dark"]) .view-opt input { accent-color: var(--gold); }
:where(:root[data-theme="dark"]) .badge.bot { background: #6B7F94; }
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .pv-tabs b { background: var(--gold); color: var(--on-gold); } }
:where(:root[data-theme="dark"]) .pv-tabs b { background: var(--gold); color: var(--on-gold); }

/* рабочие разделы: строка ссылок под шапкой и страницы во всю ширину */
.work-nav { display: flex; flex-wrap: wrap; gap: 0 10px; padding: 0 10px; background: var(--head); }
.work-nav a { flex: none; padding: 6px; font-size: 13px; font-weight: 600; color: var(--head-text); text-decoration: none; white-space: nowrap; border-radius: 6px; }
.work-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.work-nav a[aria-current="page"] { color: var(--gold); }
.side > .work-nav { padding-bottom: 4px; }
.work { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.work-top { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--head); border-bottom: 1px solid var(--head-line); }
.work-top .work-nav { padding: 0; flex: 1; min-width: 0; }
.work-brand { flex: none; font-family: var(--serif); font-size: 22px; font-weight: 500; color: #fff; text-decoration: none; }
.work-body { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 24px 16px; box-sizing: border-box; }
.work-body h1 { margin: 0 0 8px; }
/* вкладки внутри раздела — как вкладки списка чатов, подчёркивание золотом */
.work-tabs { display: flex; gap: 4px 18px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.work-tabs a { padding: 8px 2px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.work-tabs a:hover { color: var(--text); }
.work-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--gold); }
@media (max-width: 600px) {
  .work-top { flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 10px; }
  .work-brand { padding: 0 6px; }
}

/* Требования */
.tr-banner { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: rgba(212,166,74,.18); color: var(--text); font-size: 13px; font-weight: 600; }
.tr-wrap { display: flex; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.tr-tree { width: 200px; flex: none; align-self: stretch; padding: 8px 0; background: var(--surface-2); border-right: 1px solid var(--line); }
.tr-g { padding: 10px 14px 2px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.tr-tree button.tr-i { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 12px 6px 18px; border: 0; border-left: 3px solid transparent; border-radius: 0; background: transparent; color: var(--text); font-size: 13px; font-weight: 400; text-align: left; }
.tr-tree button.tr-i:hover { background: rgba(127,127,127,.12); }
.tr-tree button.tr-i.on { background: rgba(127,127,127,.16); font-weight: 700; border-left-color: var(--gold); }
.tr-n { flex: none; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.tr-n.grey { background: #6B7F94; }
.tr-select { display: none; width: 100%; margin: 0 0 10px; }
.tr-main { flex: 1; min-width: 0; padding: 10px 12px; }
.tr-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.tr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-main button.tr-chip { padding: 3px 11px; border: 1px solid var(--line); border-radius: 14px; background: transparent; color: var(--text); font-size: 12px; font-weight: 500; }
.tr-main button.tr-chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tr-q { flex: 1; min-width: 140px; max-width: 320px; margin-left: auto; padding: 4px 10px; border-radius: 14px; font-size: 13px; }
.tr-scroll { overflow-x: auto; }
.tr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tr-table th { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tr-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tr-table td small { display: block; color: var(--muted); font-size: 11px; }
.tr-table td small.bad { color: var(--bad); font-weight: 600; }
.tr-row { cursor: pointer; }
.tr-row:hover, .tr-row.open { background: rgba(127,127,127,.09); }
.tr-st { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tr-st.amber { background: var(--st-amber-bg); color: var(--st-amber); }
.tr-st.red { background: var(--st-red-bg); color: var(--st-red); }
.tr-st.green { background: var(--st-green-bg); color: var(--st-green); }
.tr-st.grey { background: var(--st-grey-bg); color: var(--st-grey); }
.tr-go { color: var(--accent-text); font-weight: 600; white-space: nowrap; text-decoration: none; }
.tr-go:hover { text-decoration: underline; }
.tr-edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; padding: 6px 4px 10px; }
.tr-edit > small { flex-basis: 100%; }
.tr-edit .tr-comment { flex: 1 1 320px; max-width: 50%; }
.tr-edit.tr-bind { align-items: center; }
.tr-edit textarea { width: 100%; box-sizing: border-box; }
.tr-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.tr-check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; align-self: center; }
.tr-check input { margin: 0; width: auto; flex: none; }
.tr-select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.tr-legacy-bar { margin: 0 0 8px; }
@media (max-width: 760px) {
  .tr-wrap { display: block; border: 0; background: transparent; overflow: visible; }
  .tr-tree { display: none; }
  .tr-select { display: block; }
  .tr-main { padding: 0; }
  .tr-q { max-width: none; margin-left: 0; width: 100%; }
  .tr-chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .tr-main button.tr-chip { flex: none; padding: 3px 8px; font-size: 11px; white-space: nowrap; }
  .tr-edit .tr-comment { max-width: 100%; flex-basis: 100%; }
  .tr-edit { flex-direction: column; align-items: stretch; }
}
@media (max-width: 640px) {
  .tr-scroll { overflow-x: visible; }
  .tr-table, .tr-table tbody { display: block; }
  .tr-table thead { display: none; }
  .tr-table tr.tr-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
  .tr-table tr.tr-row td { border: 0; padding: 0; min-width: 0; overflow-wrap: anywhere; }
  .tr-table td.c-chk { order: 0; }
  .tr-table td.c-date { order: 1; font-weight: 700; }
  .tr-table td.c-client { order: 2; flex: 1; }
  .tr-table td.c-client div, .tr-table td.c-client small { display: inline; }
  .tr-table td.c-client small { margin-left: 6px; }
  .tr-table td.c-doc { order: 3; flex-basis: 100%; }
  .tr-table td.c-dl { order: 4; }
  .tr-table td.c-dl div, .tr-table td.c-dl small { display: inline; }
  .tr-table td.c-dl small { margin-left: 4px; }
  .tr-table td.c-dl div::before { content: "до "; }
  .tr-table td.c-st { order: 5; }
  .tr-table td.c-go { order: 6; margin-left: auto; }
  .tr-table td.c-resp { order: 7; flex-basis: 100%; }
  .tr-table td.c-empty { display: none; }
  .tr-table tr.tr-detail { display: block; }
  .tr-table tr.tr-detail td { display: block; border: 0; padding: 0; }
}

/* Голосовые: 🎤 на месте «Отправить», пока поле пустое; полоса записи вместо поля ввода. */
.mic { min-height: 44px; min-width: 44px; font-size: 20px; padding: 0 12px; }
.recbar { display: flex; gap: 10px; align-items: center; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.recbar[hidden], .composer[hidden], .mic[hidden], #send[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: rec-blink 1s infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 40px; }
.rec-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rec-send { min-height: 44px; }
@keyframes rec-blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
@media (max-width: 480px) { .rec-label { display: none; } #rec-cancel { margin-left: auto; } }

/* Телефон: удержание пальца на сообщении открывает меню — без выделения текста и меню браузера (копировать — «Скопировать»). */
@media (pointer: coarse) {
  .msg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .msg img, .msg a { -webkit-user-drag: none; }     /* iPhone: удержание на фото не «поднимает» его для перетаскивания */
  input, textarea, select { font-size: 16px; }    /* iPhone/iPad не увеличивают страницу при вводе (и в альбомном виде) */
  body.kb .composer, body.kb .recbar { padding-bottom: 10px; }   /* клавиатура открыта — без отступа под «чёлку» */
  /* Окно — по видимой части экрана: шапка с собеседником всегда сверху, и с клавиатурой тоже. */
  body.app .layout { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); }
  .messages { overscroll-behavior: contain; }
}
