/* ===== Новое оформление (макет): светлый рабочий интерфейс, тёмно-синяя шапка, белые таблицы, синие акценты.
   Слой поверх style.css: меняет только внешний вид — правила, данные и поведение не трогает.
   Шрифт Inter (OFL, свои файлы, без внешних сервисов); фирменное «Правильные решения» — прежним Cormorant Garamond. ===== */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/inter-400-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/inter-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: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/inter-500-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/inter-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: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/inter-600-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/inter-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: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/inter-700-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/inter-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; }

:root {
  --navy: #132F4C; --navy2: #1B3D61;
  --brand-gold: #B99249;                       /* фирменный акцент: только логотип и редкие метки */
  --gold: #2457A6;                             /* прежние «золотые» выделения (рамки, подчёркивания, фокус) → синие */
  --sans: "Inter", "Segoe UI", Arial, sans-serif;
  --serif: var(--sans);                        /* заголовки — Inter; логотип задан отдельно */
  --logo: "Cormorant Garamond", Georgia, serif;
  --radius: 10px;
  --bg: #F4F6F8; --surface: #FFFFFF; --surface-2: #F0F3F7; --mine: #E8EFFA;
  --text: #1E2D3D; --muted: #526477; --line: #DCE2E9; --line-strong: #C3CDD8;
  --primary: #2457A6; --primary-hover: #1C4787; --on-primary: #FFFFFF; --accent-text: #2457A6;
  --select: #E8EFFA;
  --head: #132F4C; --head-text: #C9D6E4; --head-line: rgba(255,255,255,.10);
  --bad: #B42318; --error-bg: #FDECEA; --focus: rgba(36,87,166,.28);
  --shadow: 0 1px 2px rgba(19,47,76,.06);
  --st-amber-bg: #FFF3D6; --st-amber: #7A4E00; --st-red-bg: #FDECEA; --st-red: #B42318;
  --st-green-bg: #E5F4EA; --st-green: #1B6B3A; --st-grey-bg: #EEF1F4; --st-grey: #4A5868;
  --st-blue-bg: #E8EFFA; --st-blue: #1F4E96;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --gold: #7FA8E8; --primary: #7FA8E8; --primary-hover: #9BBCEE; --on-primary: #0B1E33; --accent-text: #9BBCEE;
    --select: #21456E; --line-strong: rgba(255,255,255,.24); --st-blue-bg: rgba(127,168,232,.2); --st-blue: #BBD0F2; }
}
:root[data-theme="dark"] { --gold: #7FA8E8; --primary: #7FA8E8; --primary-hover: #9BBCEE; --on-primary: #0B1E33; --accent-text: #9BBCEE;
  --select: #21456E; --line-strong: rgba(255,255,255,.24); --st-blue-bg: rgba(127,168,232,.2); --st-blue: #BBD0F2; }

body { font: 15px/1.5 var(--sans); font-feature-settings: "cv11" 1; }
h1, h2 { font-family: var(--sans); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 25px; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input, textarea { border-radius: 8px; border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }

/* ---------- Кнопки: основная (синяя), дополнительная (белая с рамкой), ссылка ---------- */
button { min-height: 38px; padding: 7px 16px; border-radius: 8px; font-weight: 600; }
button:hover { background: var(--primary-hover); }
.btn-outline, button.btn-outline, button.small { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
button.small { min-height: 32px; padding: 4px 12px; border-radius: 8px; font-size: 13px; }
button.small:hover, .btn-outline:hover, button.btn-outline:hover { background: var(--surface-2); border-color: #9AA9BA; }
button.link:hover { color: var(--primary); }
.btn-gold, button.btn-gold { background: var(--primary); color: var(--on-primary); }
.btn-gold:hover, button.btn-gold:hover, button.btn-gold:hover { background: var(--primary-hover); color: var(--on-primary); }
button.danger, button.small.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) button:hover { background: var(--primary-hover); }
}
:where(:root[data-theme="dark"]) button:hover { background: var(--primary-hover); }
.svg-i { width: 20px; height: 20px; flex: none; display: block; }

/* ---------- Шапка ---------- */
.work-top { min-height: 52px; padding: 6px 16px; background: var(--head); }
.work-brand, .page .brand, .top h1 { font-family: var(--logo); font-weight: 500; }
.work-brand { font-size: 23px; color: #fff; padding-right: 10px; margin-right: 4px; border-right: 1px solid rgba(185,146,73,.55); }
.work-brand::first-letter { color: var(--brand-gold); }
.work-nav { gap: 0 2px; }
.work-nav a { padding: 8px 10px; font-size: 14px; font-weight: 500; color: #D5E0EC; border-radius: 6px; }
.work-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.work-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--brand-gold); }
.nav-count { min-width: 20px; line-height: 20px; font-size: 12px; background: #D64535; }
.work-logout button.link, .work-top .gear { color: #D5E0EC; }
.work-logout button.link:hover, .work-top .gear:hover, .work-top .gear:focus-visible { color: #fff; }
.work-top :focus-visible { outline-color: #9BBCEE; }

/* ---------- Рабочие страницы ---------- */
.work-body { padding: 20px 24px 32px; max-width: 1480px; }
.work-body h1 { margin: 0 0 12px; font-size: 25px; }
.work-tabs { gap: 2px 20px; margin-bottom: 14px; border-bottom-color: var(--line); }
.work-tabs a { padding: 8px 2px 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.work-tabs a:hover { color: var(--text); }
.work-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.work-tabs.vypiski-sub { border-bottom: 0; gap: 6px; }
.work-tabs.vypiski-sub a { padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px; margin: 0; }
.work-tabs.vypiski-sub a[aria-current="page"] { background: var(--select); border-color: var(--primary); color: var(--primary); }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.error { border-radius: 8px; }
.work-back { color: var(--primary); border-color: var(--line-strong); border-radius: 8px; }

/* Справка вместо длинного абзаца: свёрнута, раскрывается по нажатию */
details.hint { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
details.hint > summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; color: var(--primary); font-weight: 600; list-style: none; }
details.hint > summary::-webkit-details-marker { display: none; }
details.hint > summary::before { content: "i"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--select); font: 700 12px/1 var(--sans); }
details.hint > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
details.hint[open] > summary::after { content: "▴"; }
details.hint > div { padding: 0 12px 10px 38px; color: var(--text); }
details.hint p { margin: 6px 0; max-width: 95ch; }
details.hint ul { margin: 6px 0; padding-left: 18px; max-width: 95ch; }

/* ---------- Поля отбора и фильтры ---------- */
.uk-sel, .ot-f select, .ot-period select, .tr-select, .clients-filter select, .mail-tools select {
  min-height: 36px; padding: 5px 30px 5px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background-color: var(--surface);
  color: var(--text); font-size: 14px; }
.ep-q, .tr-q, .ot-q, #q { min-height: 36px; padding: 6px 12px; border-radius: 8px; font-size: 14px; border: 1px solid var(--line-strong); background: var(--surface); }
#q { margin: 8px 12px 10px; }
/* фильтр — компактная «таблетка»; выбранный: светло-синий фон и синяя рамка (не похож на кнопку действия) */
.tr-main button.tr-chip, .ep-chip, .den-pills button, button.small.filter {
  min-height: 32px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500; }
.tr-main button.tr-chip:hover, .ep-chip:hover, .den-pills button:hover { background: var(--surface-2); border-color: #9AA9BA; }
.tr-main button.tr-chip.on, .ep-chip.on, .den-pills button[aria-pressed="true"] {
  background: var(--select); border-color: var(--primary); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary); }
.km-seg { border-color: var(--line-strong); border-radius: 8px; background: var(--surface); }
.km-seg a { padding: 6px 14px; font-size: 13px; font-weight: 500; }
.km-seg a[aria-current="page"] { background: var(--select); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary); }
.ms-btn { min-height: 36px; border-radius: 8px; border-color: var(--line-strong); font-size: 14px; }
.ms-btn.set { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--select); }

/* ---------- Статусы: компактная плашка, цвет + текст; без вида кнопки ---------- */
.tr-st, .pill, .zk, .ep-pill, .nap-pill, .uk-chip, .km-chip, .tag, .ot-flag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; line-height: 1.45; white-space: nowrap; }
.tr-st.amber, .p-amber, .zk-wait, .uk-wait, .uk-need, .uk-close, .nap-pill-nosum, .nap-pill-nochat, .ot-flag { background: var(--st-amber-bg); color: var(--st-amber); }
.tr-st.red, .p-red, .zk-err, .uk-overdue, .km-chip-red { background: var(--st-red-bg); color: var(--st-red); }
.tr-st.green, .p-green, .zk-done, .zk-closed, .nap-pill-ready { background: var(--st-green-bg); color: var(--st-green); }
.tr-st.grey, .p-grey, .zk-skip, .nap-pill { background: var(--st-grey-bg); color: var(--st-grey); }
.nap-pill-sent { background: var(--st-blue-bg); color: var(--st-blue); }
.zk-na { color: var(--muted); font-size: 13px; }
/* «не отмечено» — пустая рамка: отметки нет, но это не значит «не начато» */
.zk-none { display: inline-block; padding: 1px 8px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
/* статус, который можно поменять: видна стрелка раскрытия */
button.zk-cell, button.zk-cell:hover { border-radius: 7px; padding: 1px; }
button.zk-cell::after { content: "▾"; margin-left: 4px; font-size: 11px; color: var(--muted); }
button.zk-cell:hover .zk, button.zk-cell:hover .zk-none { box-shadow: 0 0 0 1px var(--primary); }
button.zk-cell:focus-visible { outline: 2px solid var(--primary); }

/* ---------- Таблицы ---------- */
.ep-table, .tr-table, .uk-table { font-size: 14px; font-variant-numeric: tabular-nums; }
.ep-table { border-color: var(--line); border-radius: var(--radius); background: var(--surface); }
.ep-table th, .tr-table th { padding: 9px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: #F8FAFC; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.ep-table thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.ep-table thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
.ep-table td, .tr-table td { padding: 10px; border-bottom: 1px solid var(--line); }
.ep-table tbody tr:hover td { background: #F7F9FC; }
.ep-table td small, .tr-table td small { font-size: 12.5px; }
.uk-name a { color: var(--text); font-weight: 600; }
.uk-name a:hover { color: var(--primary); }
.ipu-inn, .ep-inn, .uk-inn { font-size: 12.5px; }
.num, td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ep-table th, :root:not([data-theme="light"]) .tr-table th { background: rgba(255,255,255,.04); }
  :root:not([data-theme="light"]) .ep-table tbody tr:hover td { background: rgba(255,255,255,.04); }
}
:root[data-theme="dark"] .ep-table th, :root[data-theme="dark"] .tr-table th { background: rgba(255,255,255,.04); }
:root[data-theme="dark"] .ep-table tbody tr:hover td { background: rgba(255,255,255,.04); }

/* меню строки: редкие и опасные действия («Удалить») — отдельно от «Изменить» */
.row-menu { position: relative; display: inline-block; vertical-align: middle; }
.row-menu > summary { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); cursor: pointer; list-style: none; font-size: 18px; line-height: 1; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.row-menu > div { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 160px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(19,47,76,.14); }
.row-menu > div button { display: block; width: 100%; min-height: 34px; padding: 6px 10px; text-align: left; background: transparent; border: 0; border-radius: 6px; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; }
.row-menu > div button:hover { background: var(--surface-2); }
.row-menu > div button.danger-item { color: var(--bad); }
.row-menu > div button.danger-item:hover { background: var(--st-red-bg); }
button.btn-edit { min-height: 32px; padding: 4px 12px; font-size: 13px; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
button.btn-edit:hover { background: var(--surface-2); }
.nap-btns { white-space: nowrap; text-align: right; }
button.nap-link, button.nap-link:hover { color: var(--primary); }

/* ================= ЧАТЫ ================= */
.layout { grid-template-columns: var(--side-w, minmax(320px, 372px)) 1fr; }
.side { background: var(--surface); border-right: 1px solid var(--line-strong); }
.sections { min-height: 50px; gap: 0; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sections button { font-size: 14px; font-weight: 600; color: var(--muted); border-bottom-width: 2px; min-height: 48px; }
.sections button:hover { color: var(--text); background: transparent; }
.sections button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
/* фильтры списка — все видны: переносятся на вторую строку, без скрытой прокрутки */
.tabs, .tabs:has(> [data-tab="new"]:not([hidden])):has(> [data-tab="personal"]:not([hidden])) {
  flex-wrap: wrap; overflow: visible; gap: 6px; padding: 10px 12px 2px; margin: 0; border-bottom: 0; }
.tabs button, .tabs:has(> [data-tab="new"]:not([hidden])):has(> [data-tab="personal"]:not([hidden])) button {
  flex: 0 0 auto; min-height: 30px; padding: 3px 11px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--select); border-color: var(--primary); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary); }
.count { min-width: 20px; padding: 0 6px; background: var(--primary); color: #fff; font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
.tabs .count { line-height: 18px; min-width: 18px; font-size: 11.5px; }
.list { border-top: 1px solid var(--line); margin-top: 6px; }
.row { padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--line); }
.row:hover { background: #F7F9FC; }
.row.active { background: var(--select); box-shadow: inset 3px 0 0 var(--primary); }
.row-title { font-size: 15px; font-weight: 600; color: var(--text); }
.row-client { font-size: 13px; color: var(--muted); }
.row-preview { font-size: 14px; color: var(--muted); }
.row-at { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .row-bottom { gap: 6px; }
.badge { padding: 1px 5px; border-radius: 4px; font-size: 10.5px; letter-spacing: .02em; }
.badge.tg { background: #2A8BD0; }
.badge.max { background: #6B48E0; }
.row .pill { font-size: 12px; padding: 0 6px; line-height: 20px; }
.row-new, .unbound { border-radius: 5px; background: var(--st-blue-bg); color: var(--st-blue); }
.splitter:hover::after, .splitter.drag::after { background: var(--primary); }
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .row:hover { background: rgba(255,255,255,.04); } }

/* шапка переписки */
.layout .chat-head, .card-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 18px; font-weight: 600; letter-spacing: 0; }
.chat-head .muted { font-size: 13px; }
.info-btn, .find-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; min-height: 0; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); }
.info-btn:hover, .find-btn:hover, .info-btn:focus-visible, .find-btn:focus-visible { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.find-btn { margin-left: 0; }
button.small.bind-btn { border-color: var(--primary); color: var(--primary); }
button.small.bind-btn:hover { background: var(--select); color: var(--primary); }
.pane, .pane-empty { background: var(--bg); }
.pane-empty p { font-family: var(--sans); font-size: 16px; color: var(--muted); }

/* сообщения: входящие белые, исходящие светло-синие; ширина по тексту, длинным — удобная граница */
.messages { gap: 8px; padding: 18px 24px; }
.msg { align-self: flex-start; width: fit-content; min-width: 120px; max-width: min(680px, 78%); padding: 8px 12px 6px; border: 1px solid #E1E7EE;
  border-radius: 12px; border-top-left-radius: 4px; background: var(--surface); box-shadow: none; font-size: 15px; line-height: 1.5; }
.msg.mine { align-self: flex-end; background: var(--mine); border-color: #D3E0F4; border-top-left-radius: 12px; border-top-right-radius: 4px; }
.who { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 1px; }
.msg.mine .who { color: #3B5B87; }
.body { color: var(--text); }
.meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quote { border-left-color: var(--primary); background: var(--surface-2); color: var(--text); }
.msg.mine .quote { background: rgba(255,255,255,.7); }
.actions { border-top-color: var(--line); }
.msg.current { outline: 2px solid var(--primary); }
mark { background: #FFE7A3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg { border-color: rgba(255,255,255,.08); }
  :root:not([data-theme="light"]) .msg.mine { border-color: rgba(127,168,232,.25); }
  :root:not([data-theme="light"]) .msg.mine .who { color: var(--accent-text); }
}
:root[data-theme="dark"] .msg { border-color: rgba(255,255,255,.08); }
:root[data-theme="dark"] .msg.mine .who { color: var(--accent-text); }

/* поле ввода */
.composer { gap: 10px; padding: 10px 16px 12px; background: var(--surface); border-top: 1px solid var(--line); }
.box { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.box button.icon { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 8px; color: var(--muted); }
.box button.icon:hover { background: var(--surface-2); color: var(--text); }
.box button.icon[aria-expanded="true"] { background: var(--select); color: var(--primary); }
#send { min-height: 42px; padding: 0 18px; display: inline-flex; align-items: center; gap: 8px; }
/* голосовое — круглая кнопка с микрофоном, отличается от «Отправить» */
button.mic, #mic { display: inline-grid; place-items: center; width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%; background: var(--surface); color: var(--primary); border: 1px solid var(--line-strong); }
button.mic:hover, #mic:hover { background: var(--select); border-color: var(--primary); }
#mic[hidden], #send[hidden] { display: none; }

/* ================= ТРЕБОВАНИЯ ================= */
.tr-banner { border-radius: 8px; background: var(--st-amber-bg); color: var(--st-amber); }
.tr-wrap { border-radius: var(--radius); border-color: var(--line); }
.tr-tree { width: 210px; background: #F8FAFC; }
.tr-g { font-size: 12px; color: var(--muted); letter-spacing: .05em; }
.tr-tree button.tr-i { font-size: 14px; border-left-width: 3px; }
.tr-tree button.tr-i:hover { background: var(--surface-2); }
.tr-tree button.tr-i.on { background: var(--select); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.tr-n { min-width: 20px; font-size: 12px; line-height: 20px; }
.tr-main { padding: 12px 14px; }
.tr-filters { gap: 8px; margin-bottom: 10px; }
@media (min-width: 641px) { .tr-table { table-layout: fixed; min-width: 900px; } }
.tr-table th { white-space: nowrap; }
.tr-table th.c-chk { width: 36px; }
.tr-table th.c-date { width: 92px; }
.tr-table th.c-client { width: 21%; }
.tr-table th.c-dl { width: 118px; }
.tr-table th.c-st { width: 210px; }
.tr-table th.c-resp { width: 150px; }
.tr-table th.c-go { width: 92px; }
.tr-table td { overflow-wrap: anywhere; }
.tr-table td.c-date, .tr-table td.c-dl { white-space: nowrap; }
.tr-table td.c-dl div { font-weight: 600; }
.tr-table td small.bad { color: var(--st-red); font-weight: 600; }
/* описание документа — две строки; полный текст — по нажатию на строку (раскрывается под ней) */
.tr-table td.c-doc small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tr-table tr.open td.c-doc small { -webkit-line-clamp: unset; display: block; }
.tr-table td.c-st .tr-st, .tr-table td.c-st .pill { display: block; width: fit-content; max-width: 100%; margin: 0 0 3px; white-space: normal; }
.tr-table td.c-resp { font-size: 13.5px; }
.tr-row:hover, .tr-row.open { background: #F7F9FC; }
.tr-go { color: var(--primary); }

/* ================= ОТЧЁТЫ ================= */
.ot-scroll { border-color: var(--line); border-radius: var(--radius); }
.ot-table { font-size: 13px; font-variant-numeric: tabular-nums; }
.ot-table th, .ot-table td { border-right-color: #EEF1F5; border-bottom-color: #E6EBF0; }
.ot-table thead th { font-size: 12px; color: var(--muted); background: #F8FAFC; }
.ot-name { font-size: 14px; }
.ot-name:hover { color: var(--primary); }
.ot-inn { font-size: 12px; }
.ot-st { min-width: 58px; border-width: 1px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.ot-st.st-err { border-color: transparent; }
.ot-st.st-nd { border: 1px dashed #D8908A; }
.ot-st.st-nd.late { border: 1px solid transparent; background: var(--st-red-bg); }
.ot-st.st-wait { border: 1px solid #E0B865; }
.ot-st.st-review { border-width: 1px; }
button.ot-st:hover { filter: none; outline: 2px solid var(--primary); outline-offset: -1px; }
/* незаполненная карточка: спокойная метка вместо яркой плашки в каждой ячейке */
.ot-flag.card, .ot-st.st-card { background: transparent; color: var(--st-card); border: 1px solid #C7CEEA; }
.ot-warn { background: var(--st-amber-bg); }
.ot-total { border-radius: 8px; border-color: var(--line); padding: 4px 10px; }
.ot-total b { color: var(--text); }
button.ot-add { color: var(--primary); }
.ot-splitter:hover::after, .ot-splitter.drag::after { background: var(--primary); }

/* ================= ПАТЕНТЫ И ВЗНОСЫ ================= */
.ep-bar { gap: 8px 10px; }
.ipu .ipu-add { background: var(--primary); }
.ipu-table td { vertical-align: top; }
.ipu-table .sum, .ipu-table td.sum { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.ipu-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ipu-dates { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ipu-pays { min-width: 330px; }
.ipu-pay { display: grid; grid-template-columns: 96px 112px auto; gap: 8px; align-items: center; margin: 3px 0; font-variant-numeric: tabular-nums; }
.ipu-pay .pay-sum { text-align: right; white-space: nowrap; font-weight: 500; }
.ipu-pay .pay-date { white-space: nowrap; color: var(--muted); }
select.ipu-st { min-height: 28px; padding: 2px 24px 2px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent;
  background-color: var(--st-grey-bg); color: var(--st-grey); cursor: pointer; }
select.ipu-st:hover, select.ipu-st:focus { border-color: var(--primary); }
.ipu-pay-sent select.ipu-st, select.ipu-st-sent { background-color: var(--st-blue-bg); color: var(--st-blue); }
.ipu-pay-paid select.ipu-st, select.ipu-st-paid { background-color: var(--st-green-bg); color: var(--st-green); }
.ipu-pay-over select.ipu-st { background-color: var(--st-red-bg); color: var(--st-red); }
.ipu-emp { font-weight: 600; font-size: 14px; }
.ipu-emp-no { color: var(--st-green); } .ipu-emp-yes { color: var(--st-blue); } .ipu-emp-unknown { color: var(--st-amber); }
.ipu-table textarea.ipu-note { min-height: 36px; border-color: var(--line-strong); font-size: 13.5px; }
.ipu-table input.ipu-in { border-color: var(--line-strong); border-radius: 6px; background: var(--surface); font-size: 14px; }
.ipu-table input.ipu-in.money { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
/* «Взносы»: две группы колонок — фиксированные и 1% */
.ipu-table thead tr.grp th { text-align: center; font-size: 13px; color: var(--text); background: #EEF2F7; border-bottom: 1px solid var(--line); }
.ipu-table thead tr.grp th.g-fixed { box-shadow: inset 3px 0 0 var(--primary); }
.ipu-table thead tr.grp th.g-pct { box-shadow: inset 3px 0 0 var(--brand-gold); }
.ipu-table td.g-start, .ipu-table th.g-start { border-left: 2px solid var(--line-strong); }
.save-st { display: inline-block; min-width: 72px; font-size: 12px; color: var(--muted); }
.save-st.ok { color: var(--st-green); } .save-st.bad { color: var(--st-red); }

/* ================= ЗАКРЫТИЕ ПЕРИОДА ================= */
.zk-table td { white-space: nowrap; }
.zk-total { font-variant-numeric: tabular-nums; }
.zk-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* ================= МОЙ ДЕНЬ ================= */
.den { max-width: 1040px; }
.den-num { border-radius: 10px; border-color: var(--line); padding: 10px 16px; min-width: 150px; }
.den-num b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.den-num span { font-size: 13px; color: var(--muted); }
.den-over b { color: var(--st-red); }
.den-group h2 { margin: 20px 0 8px; font-size: 14px; }
.den-g-over { background: var(--st-red-bg); color: var(--st-red); }
.den-g-today { background: var(--st-amber-bg); color: var(--st-amber); }
.den-g-week { background: var(--st-grey-bg); color: var(--st-grey); }
.den-list { gap: 6px; }
.den-item { grid-template-columns: minmax(0, 1fr) 120px auto; gap: 14px; padding: 10px 14px; border-radius: 10px; border-color: var(--line); border-left-width: 3px; }
.den-item.den-over { border-left-color: var(--st-red); }
.den-item.den-today { border-left-color: #D39A1E; }
.den-item.den-week { border-left-color: #9AA9BA; }
.den-src { order: 2; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.den-main { order: 1; }
.den-act { order: 3; }
.den-title { font-size: 15px; }
.den-meta { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.den-item.expanded .den-meta { -webkit-line-clamp: unset; display: block; }
.den-act { border-color: var(--line-strong); border-radius: 8px; padding: 5px 12px; color: var(--primary); }
.den-act:hover { border-color: var(--primary); background: var(--select); }

/* ================= НАПОМИНАНИЯ ================= */
.nap-batch { border-radius: var(--radius); }
.nap-head h2 { font-size: 16px; font-weight: 600; }
.nap-text { max-width: 440px; font-size: 13.5px; }
.nap-text summary { color: var(--primary); font-weight: 500; }
.nap-full { padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }

/* ================= КОМАНДА ================= */
.km-sum { background: var(--surface); border-color: var(--line); border-radius: 10px; min-width: 170px; padding: 10px 16px; }
.km-sum b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.km-sum span { font-size: 13px; color: var(--muted); }
.km-red { color: var(--st-red); }
.km-card h2 { font-size: 16px; font-weight: 600; }
.km-bar { font-size: 14px; grid-template-columns: 150px minmax(0, 1fr) 100px; }
.km-track { background: #E8EDF3; height: 10px; }
.km-track i { background: var(--primary); }
.km-track i.km-slow { background: #D64535; }
.km-v { font-variant-numeric: tabular-nums; }
.km-note { font-size: 13px; }
.km-part { margin: 22px 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* ---------- Карточка клиента, окна ---------- */
.card-hero { border-bottom: 3px solid var(--brand-gold); }
.card-name { font-family: var(--sans); font-weight: 600; font-size: 32px; letter-spacing: -.01em; }
.card-hero .fact { border-color: rgba(255,255,255,.28); border-radius: 8px; }
.sec-head h3 { font-size: 19px; font-weight: 600; }
.person h4, .branch h4 { font-size: 17px; font-weight: 600; }
.ava { box-shadow: inset 0 0 0 2px var(--line-strong); font-family: var(--sans); font-size: 16px; font-weight: 600; }
.pick:has(input:checked), .staff-chip { border-color: var(--primary); background: var(--select); }

/* ---------- Телефон ---------- */
@media (max-width: 760px) {
  .work-body { padding: 16px 16px 28px; }
  .messages { padding: 14px 12px; }
  .msg { max-width: 88%; }
  .chat-head h2 { font-size: 17px; }
  .tabs button { min-height: 32px; }
}
@media (max-width: 600px) {
  .work-top { padding: 8px 12px; }
  .work-brand { border-right: 0; }
  .work-nav a { padding: 6px 8px; }
  h1, .work-body h1 { font-size: 22px; }
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ipu-table input.ipu-ok, .ipu-table textarea.ipu-ok { border-color: var(--st-green); background: var(--st-green-bg); }
.ipu-table input.ipu-bad, .ipu-table textarea.ipu-bad { border-color: var(--st-red); background: var(--st-red-bg); }
.den-client { display: block; color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.den-client:hover { color: var(--primary); text-decoration: underline; }
.den-what { font-size: 14px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.den-meta { font-weight: 600; color: var(--muted); }
.den-over .den-meta { color: var(--st-red); }
.zk.zk-none { background: transparent; }
.km-period { align-items: center; margin-top: 8px; }
.km-period .km-part { margin: 0; }
.km .km-grid > .km-card:nth-child(n+2) { grid-column: 1 / -1; }
.km .ep-table td:not(:first-child), .km .ep-table th:not(:first-child) { text-align: right; }
.visually-hidden { left: 0; top: 0; }
/* «Патенты»: плотнее, чтобы на ноутбуке 1366 таблица помещалась; при нехватке места — прокрутка внутри таблицы, ИП закреплён слева */
.ipu .ep-scroll { overflow-x: auto; border-radius: var(--radius); }
.ipu-table { min-width: 0; }
.ipu-table td:first-child, .ipu-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 190px; max-width: 240px; box-shadow: 1px 0 0 var(--line); }
.ipu-table th:first-child { background: #F8FAFC; z-index: 2; }
.ipu-table thead tr.grp th:first-child { background: #EEF2F7; }
.ipu-cut { min-width: 170px; width: 190px; }
.ipu-pays { min-width: 0; }
.ipu-pay { grid-template-columns: 88px 100px minmax(132px, auto); gap: 6px; }
.ipu-table td.nap-btns { width: 1%; }
.ipu-table td.nap-btns { display: table-cell; }
.ipu-table td.nap-btns .btn-edit { display: inline-flex; margin-bottom: 4px; }
.ipu-emp { white-space: nowrap; }
.box textarea, .box textarea:focus { border: 0; box-shadow: none; }
/* «Отчёты»: меньше заливок и рамок — яркими остаются только «не сдано» и ошибки */
.ot-st.st-no { background: transparent; color: #7A8796; font-weight: 500; }
.ot-st.st-card, .ot-flag.card { background: transparent; border: 0; color: var(--st-card); font-weight: 500; text-decoration: underline dotted; text-underline-offset: 3px; }
.ot-st.st-todo { border: 1px dashed var(--line-strong); color: var(--text); font-weight: 500; }
.ot-st.st-nd { background: var(--st-red-bg); border: 1px solid transparent; }
.nap-head .muted { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.nap-pill-nochat { background: var(--st-grey-bg); color: var(--st-grey); }
.nap-pill-skip { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.nap-table input.ipu-in { background: var(--surface); border-color: var(--line-strong); border-radius: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.nap-table td:nth-child(2), .nap-table th:nth-child(2) { text-align: right; }
.km .km-grid { grid-template-columns: 1fr; }
button.zk-cell::after { font-size: 12px; }

@media (max-width: 640px) { .tr-table th[class] { width: auto; } }
#ipu-patents td, #ipu-patents th { padding: 9px 8px; }
#ipu-patents td:first-child, #ipu-patents th:first-child { min-width: 170px; max-width: 200px; }
#ipu-patents .ipu-emp { white-space: normal; display: inline-block; max-width: 110px; }
#ipu-patents .ipu-cut { min-width: 150px; width: 160px; }
#ipu-patents .ipu-pay { grid-template-columns: 80px 98px minmax(128px, auto); }
#ipu-patents td.nap-btns { text-align: left; }
#ipu-patents td.nap-btns .btn-edit { display: flex; margin: 0 0 4px; }
/* телефон: «Ответ не нужен» — второй строкой шапки, название клиента не сжимается */
@media (max-width: 760px) {
  .chat-head:has(#dismiss:not([hidden])) { flex-wrap: wrap; row-gap: 6px; }
  .chat-head #dismiss { order: 11; }
  .chat-head:has(#dismiss:not([hidden]))::after { content: ""; order: 9; flex-basis: 100%; height: 0; }
  .layout .chat-head:has(#dismiss:not([hidden])) { height: auto; }
}
#ipu-patents textarea.ipu-note { min-width: 0; }
#ipu-patents .ipu-cut { width: 150px; }
#ipu-patents td:first-child, #ipu-patents th:first-child { min-width: 160px; }
#ipu-patents .ipu-pay { grid-template-columns: 76px 96px minmax(148px, auto); }
.ot-st.st-card { color: var(--muted); font-weight: 400; text-decoration: none; }
button.ot-st.st-card:hover { color: var(--primary); }
@media (max-width: 760px) { .tr-chips { flex-wrap: wrap; overflow: visible; } }
.ot-card-mark { flex: none; padding: 0 6px; border-radius: 5px; background: var(--st-amber-bg); color: var(--st-amber); font-size: 12px; font-weight: 600; line-height: 20px; }
@media (max-width: 600px) {          /* телефон: строка таблицы — карточка; закреплённая колонка и выравнивание сумм не нужны */
  .ep-table td, .ep-table td:first-child, .ipu-table td:first-child, #ipu-patents td:first-child { position: static; min-width: 0; max-width: none; box-shadow: none; text-align: left; padding: 3px 0; border: 0; }
  .ep-table tbody tr:hover td { background: transparent; }
  #ipu-patents .ipu-emp { max-width: none; }
  .ep-table td.num, .ep-table td.sum, .ipu-table td.sum { text-align: left; }
  #ipu-patents .ipu-cut { width: auto; }
  #ipu-patents .ipu-pay { grid-template-columns: 84px 1fr auto; }
  .ipu-table thead tr.grp { display: none; }
  .ipu-table td.g-start { border-left: 0; }
}
@media (max-width: 600px) { .ipu-table td, .ipu-table td.nap-btns { display: block; } .ipu-table td.uk-name .ipu-inn { display: block; } .ipu-dates br { display: none; } }
@media (max-width: 600px) {
  #ipu-table td:nth-child(n+3)::before, #ipu-patents td.sum::before { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
  #ipu-table td:nth-child(3)::before { content: "Фиксированные взносы, ₽"; margin-top: 6px; }
  #ipu-table td:nth-child(4)::before { content: "Комментарий"; }
  #ipu-table td:nth-child(5)::before { content: "Статус фиксированных"; }
  #ipu-table td:nth-child(6)::before { content: "1% с дохода, ₽"; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
  #ipu-table td:nth-child(7)::before { content: "Статус 1%"; }
  #ipu-patents td.sum::before { content: "Сумма патента, ₽"; }
  #ipu-patents .ipu-pay { grid-template-columns: 80px 1fr; }
  #ipu-patents .ipu-pay select { grid-column: 1 / -1; justify-self: start; }
}

/* табло автосохранения (savestate.js) */
.savestate { position: fixed; right: 20px; bottom: 20px; z-index: 900; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; line-height: 18px; box-shadow: 0 4px 14px rgba(19, 47, 76, .14); }
.savestate[hidden] { display: none; }
.savestate::before { content: ""; flex: none; width: 14px; height: 14px; box-sizing: border-box; border-radius: 50%; }
.savestate[data-s="saving"]::before { border: 2px solid var(--line); border-top-color: var(--primary); animation: savestate-spin .8s linear infinite; }
.savestate[data-s="ok"] { color: var(--st-green); border-color: var(--st-green); background: var(--st-green-bg); }
.savestate[data-s="ok"]::before { background: var(--st-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2 6 9.6l4.5-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.savestate[data-s="err"] { color: var(--st-red); border-color: var(--st-red); background: var(--st-red-bg); cursor: pointer; }
.savestate[data-s="err"]::before { background: var(--st-red) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 3.6v4.2M7 10.3v.1' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
@keyframes savestate-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .savestate[data-s="saving"]::before { animation: none; } }
@media (max-width: 640px) { .savestate { right: 12px; bottom: 12px; } }
