/* Внешний вид всей системы (решение владельца 29.09).

   Фирменные цвета 4COLORS: основной фиолетовый 142 84 230 (шкала primary
   задана в настройках Unfold), дополнительные — голубой 192 227 255 и
   салатовый 217 227 128, чёрный и белый.

   Было «белое на белом»: фон страницы, карточки и таблицы одного цвета,
   разделены линиями в 1px. Теперь фон рабочей области светло-серый, а
   карточки белые с мягкой тенью; серые полосы-заголовки секций убраны. */

:root {
  --brand: #8e54e6;
  --brand-strong: #7a3cd6;
  --brand-blue: #c0e3ff;
  --brand-lime: #d9e380;
  --ground: #f4f3f8;
  --card: #ffffff;
  --card-line: #e8e6ef;
  --card-shadow: 0 1px 2px rgba(24, 16, 48, 0.05), 0 6px 20px rgba(24, 16, 48, 0.06);
  /* подписи у значений — тот же серый, что у подписей в списках Unfold на телефоне (не прозрачность:
     прозрачность на прозрачности давала 2.3:1 — не прочесть) */
  --text-subtle: var(--color-font-subtle-light, #6a7282);
}
html.dark {
  --text-subtle: var(--color-font-subtle-dark, #99a1af);
  --ground: #0b0d14;
  --card: #151823;
  --card-line: #242838;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* --- Фон и карточки --- */
#main { background: var(--ground) !important; }

/* секции форм */
#content fieldset.module > .form-rows,
#content .inline-group > .border,
#content .inline-group .tabular,
.doc-more > div,
.doc-summary {
  background: var(--card) !important;
  border-color: var(--card-line) !important;
  box-shadow: var(--card-shadow) !important;
}
/* заголовок секции — просто заголовок, без серой полосы (и над итогами
   документа — вровень с «Notes for the client», form_layout.js) */
#content fieldset.module > h2,
#content .doc-bottom-right > h2,
#content .inline-group > h2,
#content .inline-group h2.inline-heading {
  background: transparent !important;
  padding-left: .15rem !important;
  font-size: .9375rem;
  height: auto !important;
  margin-bottom: .6rem !important;
}

/* списки: панель поиска и таблица — одна белая карточка */
#changelist .result-list-wrapper > .grow > div.lg\:border,
#changelist-form > div.rounded-default {
  background: var(--card) !important;
  border-color: var(--card-line) !important;
}
#changelist-form > div.rounded-default { box-shadow: var(--card-shadow); }
/* подсветка строки под мышью — только там, где мышь есть: на телефоне после
   касания она «залипала» и красила каждую ячейку карточки отдельно */
@media (hover: hover) {
  #result_list tbody tr:hover > * { background: rgba(142, 84, 230, 0.04); }
  html.dark #result_list tbody tr:hover > * { background: rgba(170, 124, 239, 0.07); }
}

/* --- Кнопки: в тёмной теме — насыщенный фиолетовый, а не пастель --- */
html.dark .bg-primary-600,
html.dark .dark\:bg-primary-500,
html.dark button.bg-primary-600,
html.dark a.bg-primary-600 { background-color: var(--brand-strong) !important; color: #fff !important; }

/* --- Списки (этап 1: кнопка оплаты обрезалась, клиент в три строки) --- */
#result_list td.field-client,
#result_list td.field-client_column {
  white-space: nowrap; max-width: 15rem; text-overflow: ellipsis;
}
#result_list td.field-subject { max-width: 11rem; white-space: nowrap; text-overflow: ellipsis; }
#result_list td.field-due_column { white-space: nowrap; }
#result_list > thead > tr > th, #result_list > tbody > tr > * { padding-left: .6rem !important; padding-right: .6rem !important; }
#result_list td.field-kind_column { white-space: nowrap; }
/* Средний экран, 768–1279 px (владелец, 22.10.2026: на ~1070 px справа
   не видно Total и PDF): клиент и тема — короче, отступы — плотнее */
@media (min-width: 768px) and (max-width: 1279px) {
  #result_list td.field-client, #result_list td.field-client_column { max-width: 10rem; }
  #result_list td.field-subject { max-width: 6.5rem; }
  #result_list > thead > tr > th, #result_list > tbody > tr > * { padding-left: .4rem !important; padding-right: .4rem !important; }
}
/* Планшет, до 1023 px: темы не видно — она есть в карточке документа */
@media (min-width: 768px) and (max-width: 1023px) {
  #result_list th.column-subject, #result_list td.field-subject { display: none; }
}
/* «Record payment» в строке — значком, подпись во всплывающей подсказке */
#result_list a[href*="/record-payment/"] {
  font-size: 0 !important; gap: 0 !important; padding: .4rem !important;
}
#result_list a[href*="/record-payment/"] .material-symbols-outlined { font-size: 20px !important; }

/* --- Архив --- */
.archive-version { font-variant-numeric: tabular-nums; white-space: nowrap; }
.archive-badge {
  display: inline-block; margin-left: .35rem; padding: .1rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.archive-badge.current { background: var(--brand-lime); color: #3d4500; }
.archive-badge.old { background: rgba(120, 113, 108, 0.14); color: #57534e; }
.archive-badge.void { background: #fee2e2; color: #b91c1c; }
html.dark .archive-badge.current { background: rgba(217, 227, 128, 0.18); color: var(--brand-lime); }
html.dark .archive-badge.old { background: rgba(214, 211, 209, 0.12); color: #d6d3d1; }
html.dark .archive-badge.void { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.archive-download {
  display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .45rem;
  border: 1px solid var(--card-line); border-radius: .5rem; font-weight: 500; white-space: nowrap;
}
.archive-download:hover { border-color: var(--brand); color: var(--brand-strong); }
.archive-download .material-symbols-outlined { font-size: 18px; }

/* --- Заявка на возврат: RE клиента и «сделать кредит-ноту» (admin_refunds.make_credit_note) --- */
table.refund-receipts { border-collapse: collapse; }
table.refund-receipts td { padding: .3rem 1rem .3rem 0; vertical-align: middle; white-space: nowrap; }
table.refund-receipts td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.refund-receipts .archive-badge { margin-left: 0; }

/* --- Удаление реквизитов компании: отдельная страница с подтверждением --- */
.danger-page {
  max-width: 36rem; margin: 2rem auto; padding: 1.75rem; background: var(--card);
  border-radius: .75rem; box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: .9rem;
}
.danger-page h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
.danger-page p { margin: 0; line-height: 1.55; }
.danger-page label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .35rem; }
.danger-page input {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--card-line); border-radius: .5rem;
  font-size: 1rem; letter-spacing: .05em; background: transparent; color: inherit;
}
.danger-page .danger-error { color: #b91c1c; font-weight: 500; margin-top: .5rem; }
.danger-page .danger-actions { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.danger-page .danger-button {
  background: #b91c1c; color: #fff; border: 0; border-radius: .5rem; padding: .6rem 1.1rem;
  font-weight: 600; cursor: pointer;
}

/* --- Вход: ссылка «Return to site» никуда не ведёт — сайта у системы нет --- */
body.login a[href="/"]:has(.material-symbols-outlined),
.login a[href="/"] { display: none !important; }
/* Кнопка входа — без стрелки: подпись говорит сама за себя (06.10.2026) */
#login-form button[type=submit] .material-symbols-outlined { display: none; }

/* --- Метки проблем (сверка с реестром и т.п.) --- */
.flag {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.flag.warn { background: #fef3c7; color: #92400e; }
.flag.bad { background: #fee2e2; color: #b91c1c; }
.flag.info { background: rgba(120, 113, 108, 0.14); color: #57534e; }
html.dark .flag.warn { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
html.dark .flag.bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
html.dark .flag.info { background: rgba(214, 211, 209, 0.12); color: #d6d3d1; }
/* справка 50 ทวิ получена — ссылкой на неё */
.flag.ok { background: #dcfce7; color: #166534; text-decoration: none; }
a.flag.ok:hover { text-decoration: underline; }
html.dark .flag.ok { background: rgba(34, 197, 94, 0.18); color: #86efac; }

/* --- Карточка клиента --- */
/* поля одной ширины: адреса и email тоже не шире остальных */
#client_form textarea { max-width: 42rem; }
.lookup-wrap { display: flex !important; gap: .5rem; align-items: center; }
.lookup-wrap input { flex: 1; min-width: 0; }
.lookup-button {
  flex: none; white-space: nowrap; padding: .5rem .8rem; border-radius: .5rem; cursor: pointer;
  border: 1px solid var(--brand); background: transparent; color: var(--brand-strong);
  font-size: .8125rem; font-weight: 600;
}
.lookup-button:hover:not(:disabled) { background: rgba(142, 84, 230, 0.08); }
.lookup-button:disabled { opacity: .55; cursor: default; }
html.dark .lookup-button { color: #c4a5f5; }
.lookup-note { font-size: .8125rem; margin-top: .4rem; }
.lookup-note:empty { display: none; }

/* --- Отчёт НДС: выбор месяца --- */
.month-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  border: 1px solid var(--card-line); border-radius: .5rem; background-color: var(--card); color: inherit;
  padding: .5rem 2rem .5rem .75rem; font-size: .875rem; font-weight: 500;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

/* --- Шапка карточки документа: второстепенные действия — значками --- */
#header-inner a.icon-only { font-size: 0 !important; gap: 0 !important; padding-left: .6rem !important; padding-right: .6rem !important; }
#header-inner a.icon-only .material-symbols-outlined { font-size: 20px !important; }

/* ======================================================================
   Телефон (этап 4). Списки на узком экране — карточками: таблица, сжатая
   до 390px, прятала статус и сумму за краем, а названия ломала в 4 строки.
   Подписи значений (data-label) ставит row_actions.js из заголовков.
   ====================================================================== */
@media (max-width: 767px) {
  #changelist-form > div.rounded-default { overflow: visible !important; background: transparent !important;
    border: 0 !important; box-shadow: none !important; }
  #result_list, #result_list tbody { display: block; width: 100%; }
  #result_list thead { display: none; }
  #result_list tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
    background: var(--card); border-radius: 12px; box-shadow: var(--card-shadow);
    padding: 12px 14px; margin-bottom: 10px;
  }
  #result_list tbody tr > * {
    display: block; border: 0 !important; padding: 0 !important; height: auto !important;
    min-width: 0; white-space: normal; text-align: left;
  }
  /* галочки для массовых действий на телефоне не нужны */
  #result_list tbody tr > td.action-checkbox { display: none; }
  /* обычный список: первая колонка — заголовок карточки, остальное подписано */
  #result_list tbody tr > :nth-child(2) { grid-column: 1 / -1; font-weight: 600; font-size: 15px; }
  #result_list tbody tr > [data-label]:not(:nth-child(2)) { grid-column: 1 / -1; font-size: 13px; }
  #result_list tbody tr > [data-label]:not(:nth-child(2))::before {
    content: attr(data-label) " · "; opacity: .55;
  }
  #result_list tbody tr > td:empty { display: none; }

  /* --- документы: номер и статус, клиент, даты слева, суммы справа --- */
  #result_list tbody tr:has(> .field-number_column) {
    grid-template-areas: "num status" "client client" "date total" "due balance" "subject subject" "pdf act";
  }
  #result_list tr > .field-number_column { grid-area: num; grid-column: auto !important; }
  #result_list tr > .field-status_column { grid-area: status; grid-column: auto !important; justify-self: end; }
  #result_list tr > .field-status_column::before { content: none !important; }
  #result_list tr > .field-client { grid-area: client; font-size: 14px !important; font-weight: 500;
    white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; max-width: none; }
  #result_list tr > .field-client::before { content: none !important; }
  #result_list tr > .field-date_column { grid-area: date; grid-column: auto !important; }
  #result_list tr > .field-due_column, #result_list tr > .field-valid_until { grid-area: due; grid-column: auto !important; }
  #result_list tr > .field-total_column { grid-area: total; grid-column: auto !important; justify-self: end;
    font-size: 17px !important; font-weight: 700; }
  #result_list tr > .field-total_column::before { content: "฿" !important; opacity: .55; font-weight: 500; }
  #result_list tr > .field-balance_column, #result_list tr > .field-paid_column { grid-area: balance;
    grid-column: auto !important; justify-self: end; }
  #result_list tr > .field-subject { grid-area: subject; }
  #result_list tr > .field-pdf_column { grid-area: pdf; grid-column: auto !important; }
  #result_list tr > .field-pdf_column::before { content: none !important; }
  #result_list tr > .field-actions_holder { grid-area: act; grid-column: auto !important; justify-self: end;
    width: auto !important; }
  #result_list tr > .field-actions_holder a { margin: 0 !important; }
  #result_list tbody tr > .is-blank { display: none !important; }
  #result_list tr > .field-actions_holder::before { content: none !important; }
  #result_list tr > .field-subject:has(> :only-child:empty) { display: none; }
  /* карточка — одним куском: ячейки не подсвечиваются по отдельности (узкое окно с мышью) */
  #result_list tbody tr:hover > * { background: transparent !important; }
  /* каждая ячейка документа — точно на своём месте карточки: при «grid-column:
     auto» она занимала первое свободное, и у RE (срока оплаты нет) «Paid»
     уезжал влево под дату вместо места под суммой (владелец, 06.10.2026) */
  #result_list tbody tr:has(> .field-number_column) > .field-number_column { grid-column: num !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-status_column { grid-column: status !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-date_column { grid-column: date !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-due_column,
  #result_list tbody tr:has(> .field-number_column) > .field-valid_until { grid-column: due !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-total_column { grid-column: total !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-balance_column,
  #result_list tbody tr:has(> .field-number_column) > .field-paid_column { grid-column: balance !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-pdf_column { grid-column: pdf !important; }
  #result_list tbody tr:has(> .field-number_column) > .field-actions_holder { grid-column: act !important; }

  /* кнопка оплаты в карточке — крупнее, под палец */
  #result_list a[href*="/record-payment/"] { padding: .55rem .7rem !important; }

  /* --- карточка документа: главное действие — кнопкой внизу экрана --- */
  .mobile-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: flex; gap: 8px; align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--card); box-shadow: 0 -4px 16px rgba(24, 16, 48, 0.1);
  }
  .mobile-actions a {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; min-width: 44px; border-radius: 10px; font-weight: 600; font-size: 15px;
    border: 1px solid var(--card-line); color: inherit; text-decoration: none;
  }
  .mobile-actions a.primary { flex: 1; background: #7a3cd6; border-color: #7a3cd6; color: #fff; }
  .mobile-actions .material-symbols-outlined { font-size: 22px; }
  body.has-mobile-actions #main { padding-bottom: 76px; }
}

/* --- Импорт выписки банка --- */
.bank-page { display: flex; flex-direction: column; gap: 20px; max-width: 1180px; }
.bank-card { background: var(--card); border-radius: 14px; box-shadow: var(--card-shadow); padding: 22px 26px; }
.bank-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.bank-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
/* имя файла выписки в заголовке («These transfers were in an earlier statement») — переносится, а не
   уводит страницу вбок на телефоне */
.bank-head .bank-note { min-width: 0; overflow-wrap: anywhere; }
.bank-note { font-size: 13px; opacity: .72; margin: 0 0 14px; line-height: 1.5; }
.bank-note a { color: #7a3cd6; text-decoration: underline; text-underline-offset: 2px; }
/* перевод по уведомлению банка, выписки ещё нет (bank_notices.py) */
.bank-flag { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: rgba(122, 60, 214, .12); color: #5b2aa6; }
.bank-flag-alarm { background: rgba(185, 28, 28, .12); color: #b91c1c; }
html.dark .bank-flag { background: rgba(196, 165, 245, .16); color: #dcc9fa; }
html.dark .bank-flag-alarm { background: rgba(248, 113, 113, .16); color: #fca5a5; }
html.dark .bank-note a { color: #c4a5f5; }
.bank-error { color: #b91c1c; font-weight: 500; }
.bank-empty { font-size: 14px; opacity: .7; margin: 6px 0 0; }
.bank-upload { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.bank-upload label, .bank-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.bank-page select, .bank-page input[type=password], .bank-page input[type=file], .bank-page input[type=text] {
  border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .6rem; font-size: .875rem;
  background: var(--card); color: inherit; max-width: 100%;
}
.bank-primary {
  background: #7a3cd6; color: #fff; border: 0; border-radius: .5rem; padding: .6rem 1.1rem;
  font-weight: 600; cursor: pointer; min-height: 40px;
}
.bank-primary:hover { background: #682dba; }
.bank-queue, .bank-history, .bank-preview table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.bank-queue th, .bank-history th, .bank-preview th {
  text-align: left; font-weight: 600; font-size: 12px; opacity: .7; padding: 8px 10px; border-bottom: 1px solid var(--card-line);
}
.bank-queue td, .bank-history td, .bank-preview td { padding: 10px; border-bottom: 1px solid var(--card-line); vertical-align: top; }
.bank-queue tr.has-choice td { background: rgba(217, 227, 128, .14); }
.bank-queue .num, .bank-history .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bank-queue .strong { font-weight: 700; }
.bank-history .strong { font-weight: 600; }
/* длинное имя файла SCB переносится — колонка с датами выписки остаётся видна */
.bank-history .bank-file { max-width: 18rem; overflow-wrap: anywhere; font-size: 12.5px; }
.bank-queue .desc { max-width: 22rem; word-break: break-word; }
.bank-queue .choice { min-width: 20rem; }
.bank-queue .choice select { width: 100%; }
.bank-queue .hint { font-size: 12px; margin-top: 4px; }
/* «Not a client payment»: что это за деньги — бухгалтеру */
.bank-ignore-note { margin-top: 6px; }
.bank-ignore-note input { width: 100%; }
.bank-page .muted { opacity: .6; font-size: 12px; }
.bank-done { color: #15803d; font-weight: 600; }
.bank-wait { color: #b45309; }
.dark .bank-done { color: #4ade80; }
.dark .bank-wait { color: #fbbf24; }
.bank-page .nowrap { white-space: nowrap; }
.bank-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px 20px;
  flex-wrap: wrap; margin-top: 16px; }
/* Галка «выпустить RE» рядом с кнопкой: от неё зависят налоговые документы */
.bank-check { display: inline-flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.bank-check input { accent-color: var(--brand-strong); width: 16px; height: 16px; margin: 1px 0 0; flex: none; }
/* «Create invoice» в списке КП: дата счёта — сегодня, вчера или другая */
.invoice-date { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; border: 0; padding: 0; margin: 0 0 16px; }
.invoice-date legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.invoice-date input[type=date] { border: 1px solid var(--card-line); border-radius: .5rem; padding: .35rem .55rem;
  font-size: .875rem; background: var(--card); color: inherit; }
.bank-preview { overflow-x: auto; margin-bottom: 14px; border: 1px solid var(--card-line); border-radius: .5rem; }
.bank-preview td { white-space: nowrap; font-size: 12px; }
.bank-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 14px; }
.bank-fields fieldset { border: 0; padding: 0; margin: 0; flex-basis: 100%; }
.bank-fields legend { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.bank-fields label.inline { flex-direction: row; display: inline-flex; margin-right: 12px; font-weight: 400; }
@media (max-width: 767px) {
  .bank-card { padding: 16px; }
  .bank-queue thead { display: none; }
  .bank-queue, .bank-queue tbody, .bank-queue tr, .bank-queue td { display: block; width: 100%; }
  .bank-queue tr { padding: 10px 0; border-bottom: 1px solid var(--card-line); }
  .bank-queue td { border: 0; padding: 3px 0; }
  .bank-queue .choice { min-width: 0; }
  /* «Uploaded statements» — выписка блоком в четыре строки: дата и счёт; поступления; когда загружена;
     имя файла одной строкой. Таблица в семь колонок на телефоне не влезала: имя файла шло столбиком
     по две буквы, последние колонки уходили за край экрана (снимок владельца из приложения, 02.12.2026) */
  .bank-history, .bank-history tbody { display: block; }
  .bank-history thead { display: none; }
  .bank-history tr { display: grid; grid-template-columns: auto auto auto 1fr; gap: 2px 16px; padding: 10px 0;
    border-bottom: 1px solid var(--card-line); }
  .bank-history td { border: 0; padding: 0; min-width: 0; }
  .bank-history .bank-period { grid-area: 1 / 1 / 2 / 4; }
  .bank-history .bank-account { grid-area: 1 / 4 / 2 / 5; justify-self: end; }
  .bank-history .num { grid-row: 2; text-align: left; }
  .bank-history .bank-uploaded { grid-area: 3 / 1 / 4 / -1; opacity: 1; color: var(--text-subtle); }
  .bank-history .bank-file { grid-area: 4 / 1 / 5 / -1; max-width: none; overflow: hidden; overflow-wrap: normal;
    color: var(--text-subtle); }
  .bank-history .bank-file a { display: block; padding: 4px 0; margin: -4px 0; overflow: hidden; white-space: nowrap;
    text-overflow: ellipsis; color: inherit; }
  .bank-history .num a { display: inline-block; padding: 4px 10px; margin: -4px -10px; }
  .bank-history td[data-label]::before { content: attr(data-label) " "; font-size: 12px; color: var(--text-subtle); }
}

/* --- Свои таблицы на телефоне: класс phone-table (02.12.2026, после снимка «Uploaded statements» с
   iPhone) — строка блоком, ячейки друг под другом. У ячейки с data-label подпись слева, значение справа:
   числа и даты без подписи не понять («Tax withheld … ฿124.05»). Итог (tfoot, tr.total) — подпись и
   сумма в одну строку; пустые ячейки не показываются. Горизонтальные отступы ячеек остаются свои. --- */
@media (max-width: 767px) {
  .phone-table, .phone-table tbody, .phone-table tfoot { display: block; width: 100%; }
  .phone-table thead { display: none; }
  .phone-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--card-line); }
  .phone-table td { display: block; width: auto; border: 0; padding-top: 2px; padding-bottom: 2px;
    text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .phone-table td:empty { display: none; }
  .phone-table td[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    text-align: right; }
  .phone-table td[data-label]::before { content: attr(data-label); flex: none; font-size: 12px; font-weight: 400;
    color: var(--text-subtle); text-align: left; }
  .phone-table tfoot tr, .phone-table tr.total { display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; }
  table.phone-table tfoot td { padding-left: 0; padding-right: 0; }
  /* кнопка под текстом строки (Registry check): отступ — чтобы рамка кнопки не наезжала на текст */
  .phone-table td.phone-act { padding-top: 8px; padding-bottom: 6px; }

  /* Отчёт НДС: документ — в пять строк (№, номер и дата; покупатель; налоговый номер и филиал; сумма и
     НДС; заметка), а не таблица в девять колонок, листающаяся вбок с покупателем в узком столбике */
  .vat-table, .vat-table tbody { display: block; }
  .vat-table thead { display: none; }
  .vat-table tr { display: grid; grid-template-columns: minmax(1.75rem, auto) 1fr auto; gap: 2px 10px; padding: 10px 16px; }
  .vat-table td { padding: 0 !important; min-width: 0; white-space: normal; }
  .vat-table .vat-n { grid-area: 1 / 1; color: var(--text-subtle); }
  .vat-table .vat-doc { grid-area: 1 / 2; }
  .vat-table .vat-date { grid-area: 1 / 3; text-align: right; }
  .vat-table .vat-buyer { grid-area: 2 / 1 / 3 / -1; }
  .vat-table .vat-taxid { grid-area: 3 / 1 / 4 / 3; }
  .vat-table .vat-branch { grid-area: 3 / 3; text-align: right; }
  .vat-table .vat-value { grid-area: 4 / 1 / 5 / 3; text-align: left !important; }
  .vat-table .vat-vat { grid-area: 4 / 3; }
  .vat-table .vat-note { grid-area: 5 / 1 / 6 / -1; }
  .vat-table .vat-total .vat-label { grid-area: 1 / 1 / 2 / -1; }
  .vat-table .vat-total .vat-value, .vat-table .vat-total .vat-vat { grid-row: 2; }
  .vat-table td:empty { display: none; }
  .vat-table td[data-label]::before { content: attr(data-label) " "; font-size: 12px; font-weight: 400;
    color: var(--text-subtle); }
  /* письма на «Bank mail»: итог письма — главное в строке, время — подписью над ним */
  .mail-letters td:first-child { font-size: 12px; color: var(--text-subtle); }
  .mail-letters td:nth-child(2) { font-weight: 600; }
}

/* --- История FlowAccount: пояснение и итоги над списком, панель в карточке
   клиента, позиции документа --- */
.legacy-summary {
  display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; padding: .85rem 1rem;
  background: var(--card); border-radius: .75rem; box-shadow: var(--card-shadow);
}
.legacy-summary p { margin: 0; }
.legacy-note { display: flex; gap: .5rem; align-items: flex-start; font-size: .875rem; opacity: .8; }
.legacy-note .material-symbols-outlined, .legacy-history .material-symbols-outlined {
  font-size: 20px; color: var(--brand); flex: none;
}
.legacy-totals { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; }
.legacy-summary .num, .legacy-history .num, .legacy-items .num { font-variant-numeric: tabular-nums; }
.legacy-history {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1.5rem;
  padding: .75rem 1rem; background: var(--card); border-radius: .75rem; box-shadow: var(--card-shadow);
}
.legacy-history .grow { flex: 1 1 16rem; }
.legacy-history a { font-weight: 600; color: var(--brand-strong); white-space: nowrap; }
html.dark .legacy-history a { color: var(--brand-blue); }
.legacy-items { width: 100%; max-width: 56rem; border-collapse: collapse; font-size: .875rem; }
.legacy-items th, .legacy-items td { padding: .4rem .6rem; border-bottom: 1px solid var(--card-line);
  text-align: left; vertical-align: top; }
.legacy-items td:first-child { white-space: pre-line; }
.legacy-items .num { text-align: right; white-space: nowrap; }
a.legacy-link { color: var(--brand-strong); font-weight: 500; }
a.legacy-link:hover { text-decoration: underline; }
html.dark a.legacy-link { color: var(--brand-blue); }

/* --- Документы клиента наверху его карточки (ClientAdmin._documents_panel) --- */
.client-docs {
  margin-bottom: 1.5rem; padding: .9rem 1.1rem .8rem; background: var(--card); border-radius: .75rem;
  box-shadow: var(--card-shadow); font-size: .875rem;
}
.client-docs .num { font-variant-numeric: tabular-nums; }
.client-docs .muted { opacity: .65; }
.client-docs .material-symbols-outlined { font-size: 20px; color: var(--brand); flex: none; }
.client-docs-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.client-docs-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.client-docs-sums { margin-left: auto; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.client-docs-sums b { font-weight: 700; margin-left: .2rem; }
.client-docs-sums .overdue { color: #b91c1c; }
html.dark .client-docs-sums .overdue { color: #f87171; }
.client-docs-legacy .overdue { color: #b91c1c; }
html.dark .client-docs-legacy .overdue { color: #f87171; }
.client-docs-table { width: 100%; margin-top: .6rem; border-collapse: collapse; }
.client-docs-table td { padding: .42rem .9rem .42rem 0; border-bottom: 1px solid var(--card-line); vertical-align: middle; }
.client-docs-table td:last-child { padding-right: 0; }
.client-docs-table .nowrap { white-space: nowrap; }
.client-docs-table .kind { width: 100%; }
.client-docs-table .num { text-align: right; white-space: nowrap; }
.client-docs-table .status { white-space: nowrap; }
.client-docs-table .pdf a { font-weight: 500; opacity: .75; }
.client-docs-table .pdf a:hover { opacity: 1; text-decoration: underline; }
.client-docs-table tr.void td:not(.status) { opacity: .5; text-decoration: line-through; }
.client-docs-empty { margin: .6rem 0 0; }
.client-docs-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; margin-top: .75rem; }
.client-docs-kinds { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; margin-right: auto; }
.client-docs-kinds a {
  padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--card-line); white-space: nowrap;
}
.client-docs-kinds a:hover { border-color: var(--brand); color: var(--brand-strong); }
.client-docs-kinds b { margin-left: .2rem; }
a.client-docs-new {
  display: inline-flex; align-items: center; gap: .2rem; padding: .3rem .75rem .3rem .5rem; border-radius: .5rem;
  border: 1px solid var(--brand); color: var(--brand-strong); font-weight: 600; white-space: nowrap;
}
a.client-docs-new:hover { background: rgba(142, 84, 230, .08); }
html.dark a.client-docs-new { color: var(--brand-blue); }
a.client-docs-new .material-symbols-outlined { font-size: 18px; color: inherit; }
.client-docs-legacy {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .75rem; padding-top: .65rem;
  border-top: 1px solid var(--card-line);
}
.client-docs-legacy .grow { flex: 1 1 16rem; opacity: .8; }
.client-docs-legacy a { font-weight: 600; color: var(--brand-strong); white-space: nowrap; }
html.dark .client-docs-legacy a { color: var(--brand-blue); }
@media (max-width: 767px) {
  .client-docs-sums { margin-left: 0; flex-basis: 100%; }
  /* Строка документа — в две строки: дата и номер, ниже вид, сумма и статус */
  .client-docs-table, .client-docs-table tbody { display: block; }
  .client-docs-table tr {
    display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; padding: .5rem 0;
    border-bottom: 1px solid var(--card-line);
  }
  .client-docs-table td { border: 0; padding: 0; }
  .client-docs-table .kind { grid-column: 1 / 3; width: auto; }
  .client-docs-table .status { grid-column: 1 / 3; }
  .client-docs-table .num, .client-docs-table .pdf { justify-self: end; }
}

/* --- Аванс клиента в карточке клиента --- */
.advance-panel {
  margin-bottom: 1.5rem; padding: .75rem 1rem; background: var(--card); border-radius: .75rem;
  box-shadow: var(--card-shadow);
}
.advance-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.advance-head .grow { flex: 1 1 16rem; }
.advance-head .material-symbols-outlined { font-size: 20px; color: var(--brand); flex: none; }
.advance-panel .muted { opacity: .7; }
.advance-panel .num { font-variant-numeric: tabular-nums; }
.advance-moves { width: 100%; max-width: 44rem; margin-top: .6rem; border-collapse: collapse; font-size: .875rem; }
.advance-moves td { padding: .35rem .6rem .35rem 0; border-bottom: 1px solid var(--card-line); }
.advance-moves td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.advance-moves td.nowrap { white-space: nowrap; }
.advance-moves tr.void { opacity: .55; text-decoration: line-through; }
.advance-hint { margin: .6rem 0 0; font-size: .8125rem; }
.legacy-summary .muted { opacity: .7; }
.client-pick-wrap { position: relative; margin-top: 6px; }
.bank-queue .bank-client { width: 100%; }
.bank-queue .bank-client:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
/* Свой список подсказок клиента (client_picker.js) — в оформлении системы, светлый и тёмный */
.client-suggest {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--card-line); border-radius: .5rem;
  box-shadow: var(--card-shadow); max-height: 16rem; overflow: auto; padding: 4px;
}
.client-suggest .item { padding: .45rem .6rem; border-radius: .375rem; cursor: pointer; font-size: .8125rem; }
.client-suggest .item.active, .client-suggest .item:hover { background: rgba(142, 84, 230, .10); color: var(--brand-strong); }
html.dark .client-suggest .item.active, html.dark .client-suggest .item:hover { background: rgba(142, 84, 230, .22); color: inherit; }
.client-suggest .empty { padding: .45rem .6rem; font-size: .8125rem; opacity: .6; }

/* --- Документы клиента за месяц (ZIP) --- */
.zip-card { background: var(--card); border-radius: 14px; box-shadow: var(--card-shadow); padding: 22px 26px; }
.zip-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.zip-title { font-size: 17px; font-weight: 600; }
.zip-scroll { overflow-x: auto; }
.zip-form { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 8px; }
.zip-month { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.zip-month select { border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .6rem; font-size: .875rem;
  background: var(--card); color: inherit; }
.zip-kinds { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.zip-kinds legend { font-size: 13px; font-weight: 500; margin-bottom: 6px; padding: 0; }
.zip-kind { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--card-line); border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; cursor: pointer; user-select: none; }
.zip-kind input { accent-color: #7a3cd6; width: 15px; height: 15px; cursor: pointer; }
.zip-kind:has(input:checked) { border-color: #7a3cd6; background: rgba(122, 60, 214, .08); }
.zip-count { font-size: 12px; opacity: .65; font-variant-numeric: tabular-nums; }
.zip-download { display: inline-flex; align-items: center; gap: 6px; background: #7a3cd6; color: #fff !important;
  border-radius: .5rem; padding: .55rem 1rem; font-weight: 600; min-height: 38px; cursor: pointer; }
.zip-download:hover { background: #682dba; }
.zip-note, .zip-empty { font-size: 13px; opacity: .75; margin: 6px 0 14px; }
.zip-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.zip-table th { text-align: left; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--card-line); }
.zip-table td { padding: 8px 10px; border-bottom: 1px solid var(--card-line); }
.zip-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zip-table .muted { opacity: .6; font-size: 12px; margin-left: 4px; }
/* Ссылка для бухгалтера клиента — на той же странице */
.acc-section { margin-top: 18px; }
.acc-link { border: 1px solid var(--card-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.acc-link-new { border-color: #7a3cd6; box-shadow: 0 0 0 3px rgba(122, 60, 214, .12); }
.acc-link-off { opacity: .6; }
.acc-link-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; }
.acc-link-head .muted { opacity: .7; }
.acc-badge { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 1px 8px; background: rgba(120, 120, 140, .15); }
.acc-badge.acc-on { background: rgba(22, 163, 74, .14); color: #15803d; }
html.dark .acc-badge.acc-on { color: #4ade80; }
.acc-link-url { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.acc-link-url input { flex: 1 1 320px; min-width: 0; border: 1px solid var(--card-line); border-radius: .5rem;
  padding: .45rem .6rem; font-size: 13px; background: transparent; color: inherit; }
.acc-btn { border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .8rem; font-size: 13px;
  font-weight: 600; background: transparent; color: inherit; cursor: pointer; min-height: 34px; display: inline-flex;
  align-items: center; }
.acc-btn:hover { border-color: #7a3cd6; }
.acc-danger { color: #dc2626; }
/* «Accountant access»: над журналом — кто сейчас вошёл и разовые ссылки, крестик «Sign out» (28.10.2026) */
.acc-now { margin-bottom: 1rem; padding: .85rem 1rem; background: var(--card); border-radius: .75rem;
  box-shadow: var(--card-shadow); }
.acc-now-title { font-size: 15px; font-weight: 600; margin: 0 0 .5rem; }
.acc-now-subtitle { font-size: 13.5px; font-weight: 600; margin: 1rem 0 .4rem; }
.acc-now-scroll { overflow-x: auto; }
.acc-now-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.acc-now-table th { text-align: left; font-weight: 500; font-size: 12.5px; opacity: .7; padding: 6px 10px;
  border-bottom: 1px solid var(--card-line); white-space: nowrap; }
.acc-now-table td { padding: 8px 10px; border-bottom: 1px solid var(--card-line); vertical-align: top; }
.acc-now-table tr:last-child td { border-bottom: 0; }
.acc-now-table .nowrap { white-space: nowrap; }
.acc-now-table .muted { opacity: .6; }
.acc-now-act { text-align: right; width: 1%; white-space: nowrap; }
.acc-now-empty { margin: 0; opacity: .7; font-size: 13.5px; }
.acc-now-hint { margin: .75rem 0 0; font-size: 12.5px; opacity: .7; }
.acc-row-btn { display: inline-flex; align-items: center; gap: 2px; padding: 1px 9px 1px 5px; border-radius: 999px;
  border: 1px solid currentColor; font-size: 12.5px; font-weight: 500; white-space: nowrap; text-decoration: none; }
.acc-row-btn .material-symbols-outlined { font-size: 16px; }
.acc-row-btn:hover { background: rgba(120, 120, 140, .1); }
.acc-row-close { color: #b91c1c; }
html.dark .acc-row-close { color: #fca5a5; }
/* на телефоне строки — карточками, подпись над значением: таблица уводила «Sign out» за край экрана */
@media (max-width: 640px) {
  .acc-now-table thead { display: none; }
  .acc-now-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--card-line); }
  .acc-now-table tr:last-child { border-bottom: 0; }
  .acc-now-table td { display: block; padding: 2px 0; border: 0; white-space: normal; }
  .acc-now-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; opacity: .6; }
  .acc-now-act { text-align: left; padding-top: 6px; }
}
.acc-inline { display: inline; }
.acc-stats { font-size: 12.5px; opacity: .75; margin-top: 8px; }
.acc-events { font-size: 12.5px; margin-top: 4px; }
.acc-events summary { cursor: pointer; opacity: .8; }
.acc-events ul { margin: 6px 0 0 18px; padding: 0; list-style: disc; }
.acc-create { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-top: 14px; }
.acc-create select, .acc-create input { border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .6rem;
  font-size: .875rem; background: var(--card); color: inherit; }
.acc-note input { width: 260px; max-width: 100%; }
.acc-portal { margin: 6px 0 12px; }
.acc-access { font-size: 13.5px; margin-bottom: 10px; }
.acc-access .muted { opacity: .65; }
.acc-events-table { margin: 6px 0 14px; font-size: 13px; }
.acc-oneoff { margin-top: 10px; border-top: 1px solid var(--card-line); padding-top: 12px; }
.acc-oneoff > summary { cursor: pointer; font-weight: 600; font-size: 14px; margin-bottom: 8px; }

/* Импорт КП из PDF (QuoteAdmin.import_pdf_action) — в стиле страницы ZIP */
.qi-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 8px; }
.qi-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.qi-wide { flex: 1 1 320px; max-width: 520px; }
.qi-field input { border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .6rem; font-size: .875rem;
  background: var(--card); color: inherit; min-width: 0; }
.qi-or { font-size: 13px; opacity: .6; padding-bottom: 9px; }
.qi-source { font-size: 14px; margin: 0 0 12px; }
.qi-source .muted, .qi-panel .muted, .qi-items .muted { opacity: .65; font-size: 12.5px; }
.qi-box { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13.5px; }
.qi-box ul { margin: 4px 0 0 18px; padding: 0; list-style: disc; }
.qi-problem { background: rgba(220, 38, 38, .08); border: 1px solid rgba(220, 38, 38, .35); }
.qi-warning { background: #fef3c7; color: #92400e; }
html.dark .qi-warning { background: rgba(245, 158, 11, .15); color: #fcd34d; }
.qi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.qi-panel { border: 1px solid var(--card-line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; min-width: 0; }
.qi-panel h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.qi-panel p { margin: 0 0 8px; }
.qi-label { font-weight: 600; font-size: 13px; margin-top: 10px !important; }
.qi-list { margin: 0 0 0 18px; padding: 0; list-style: disc; overflow-wrap: anywhere; }
.qi-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.qi-dl dt { opacity: .65; }
.qi-dl dd { margin: 0; overflow-wrap: anywhere; }
.qi-diff td { overflow-wrap: anywhere; }
.qi-diff td.qi-nowrap { white-space: nowrap; overflow-wrap: normal; }
.qi-items td { vertical-align: top; }
.qi-items td:nth-child(2) { min-width: 220px; }   /* на телефоне таблица прокручивается, а не сжимает описание */
.qi-totals { max-width: 520px; margin: 14px 0 0 auto; }
.qi-ok { color: #15803d; font-weight: 700; }
.qi-bad { color: #dc2626; font-weight: 700; }
html.dark .qi-ok { color: #4ade80; }
.qi-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 18px; }
/* Номера из файла в базе нет — выбор клиента (владелец, 12.10.2026) */
.qi-options { display: flex; flex-direction: column; gap: 8px; }
.qi-option { border: 1px solid var(--card-line); border-radius: 8px; padding: 8px 10px; }
.qi-option:has(> .qi-choice input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.qi-choice { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.qi-choice input[type=radio] { margin-top: 3px; flex: none; accent-color: var(--brand); }
.qi-choice-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.qi-reason { font-size: 12.5px; color: var(--brand-strong); }
html.dark .qi-reason { color: var(--brand-blue); }
.qi-indent { margin: 6px 0 0 24px; min-width: 0; }
.qi-indent .qi-label:first-child { margin-top: 4px !important; }
.qi-input { width: 100%; border: 1px solid var(--card-line); border-radius: .5rem; padding: .45rem .6rem;
  font-size: .875rem; background: var(--card); color: inherit; }
.qi-input:focus, .qi-new-fields input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.qi-indent .client-pick-wrap { margin-top: 0; }
.qi-new-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; margin-bottom: 8px; }
.qi-new-fields .qi-field:first-child { flex: 0 1 11rem; }
.qi-new-fields .qi-grow { flex: 1 1 14rem; }
.qi-new-fields .qi-field input { width: 100%; }
.qi-check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--brand); color: var(--brand-strong);
  background: transparent; border-radius: 8px; padding: .4rem .75rem; font-size: 13px; font-weight: 600; cursor: pointer; }
.qi-check .material-symbols-outlined { font-size: 18px; }
.qi-check:hover { background: rgba(142, 84, 230, .08); }
html.dark .qi-check { color: var(--brand-blue); }
.qi-notes { margin: 0 0 8px 18px; padding: 0; list-style: disc; font-size: 13px; color: #92400e; }
html.dark .qi-notes { color: #fcd34d; }
.qi-notes-bad, html.dark .qi-notes-bad { color: #dc2626; font-weight: 600; }
.qi-confirm { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.qi-confirm input { margin-top: 2px; flex: none; accent-color: var(--brand); }
.qi-error { color: #dc2626; font-weight: 600; margin: 8px 0 !important; }
/* «Проверяем номер в реестрах…» — страница спрашивает реестры сама (quote_import.js) */
.qi-pending { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; font-size: 13px; color: var(--brand-strong); }
html.dark .qi-pending { color: var(--brand-blue); }
.qi-spinner { flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: qi-spin .8s linear infinite; }
@keyframes qi-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .qi-spinner { animation-duration: 2.4s; } }
.qi-pending-failed { color: #92400e; }
html.dark .qi-pending-failed { color: #fcd34d; }
.qi-pending-failed .qi-spinner { display: none; }

@media (max-width: 640px) {
  .zip-card { padding: 16px; }
  .zip-table th, .zip-table td { padding: 7px 6px; }
  .qi-dl { grid-template-columns: 1fr; gap: 0 0; }
  .qi-dl dd { margin-bottom: 6px; }
  .qi-indent { margin-left: 0; }     /* таблице расхождений нужна вся ширина */
}

/* Непонятно набранное число («1.500,50») — number_format.js не даёт его сохранить */
/* #items-group — перебить серую рамку полей позиций из admin_compact.css */
input.number-invalid, #items-group input.number-invalid, html.dark #items-group input.number-invalid {
  border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, .15) !important; }

/* Подсказки к окошкам отчёта по НДС (22.10.2026): значок «i» у названия,
   текст — при наведении мышью или касании (фокус на кнопке) */
.report-tile { position: relative; }
.report-tip-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; color: inherit; cursor: help;
}
.report-tip-button .material-symbols-outlined { font-size: 17px; }
.report-tip-button:hover, .report-tip-button:focus-visible { color: var(--brand-strong); }
.report-tip-button:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.report-tip-text {
  display: none; position: absolute; z-index: 30; left: .75rem; top: 2.6rem;
  width: min(20rem, calc(100vw - 2rem)); padding: 10px 12px;
  background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12); font-size: 13px; line-height: 1.45;
}
.report-tip-line { display: block; margin-top: 6px; }
.report-tip:hover .report-tip-text,
.report-tip-button:focus + .report-tip-text { display: block; }
.dark .report-tip-text { background: #1f2937; color: #e5e7eb; border-color: #374151; }

/* --- Справки 50 ทวิ: запись справки, письма клиентам, итоги над списком --- */
.certificate-form { margin-top: 18px; }
/* min-width: 0 — поле не шире строки: длинный пункт списка «Document type» выводил его за край карточки
   на телефоне (02.12.2026) */
.certificate-form .bank-fields > label { flex: 1 1 12rem; min-width: 0; }
.certificate-form .bank-fields input[type=text], .certificate-form .bank-fields input[type=date],
.certificate-form .bank-fields select { width: 100%; }
.certificate-form .bank-fields input[type=date] { border: 1px solid var(--card-line); border-radius: .5rem;
  padding: .4rem .55rem; font-size: .875rem; background: var(--card); color: inherit; }
/* в тёмной теме значок календаря у поля даты был тёмным на тёмном */
html.dark .certificate-form input[type=date], html.dark .invoice-date input[type=date] { color-scheme: dark; }
.certificate-form .bank-fields > label.certificate-scan { flex-basis: 100%; }
.certificate-scan .muted, .certificate-form .bank-error { font-weight: 400; }
.certificate-form .bank-fields > label.certificate-note { flex-basis: 100%; }
.certificate-note input { width: 100%; }
/* min-width: fieldset по умолчанию не уже содержимого — открытое письмо раздвигало страницу на телефоне */
.certificate-letter { border: 1px solid var(--card-line); border-radius: .75rem; padding: 12px 16px 14px;
  margin: 0 0 14px; min-width: 0; }
.certificate-letter legend { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 0 6px; }
.certificate-letter .strong { font-weight: 600; }
.certificate-letter .bank-fields { margin: 6px 0 10px; }
/* «To» и «Copy (cc)» — по половине строки: в копии бывает два-три адреса, узкое поле их прятало */
.certificate-letter .bank-fields > label { flex: 1 1 16rem; }
.certificate-letter .bank-fields input { width: 100%; }
.certificate-preview { margin-top: 8px; font-size: 13px; }
.certificate-preview summary { cursor: pointer; color: var(--brand-strong); }
/* «Statement of account» в карточке клиента (statements.py, 28.10.2026) */
.statement-late { color: #b91c1c; font-weight: 600; }
html.dark .statement-late { color: #fca5a5; }
.statement-table tfoot td { padding: 8px 10px; font-weight: 600; border-bottom: 0; }
.statement-table tfoot .num { text-align: right; }
.statement-actions { justify-content: flex-start; margin: 8px 0 16px; }
.statement-send { margin-top: 8px; }
.statement-sent-title { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
/* письмо — как его увидит клиент: белый лист и в тёмной теме (почта у клиента светлая) */
.certificate-preview .letter-paper { background: #fff; border: 1px solid var(--card-line); border-radius: .5rem;
  padding: 16px 18px; margin: 6px 0 0; overflow-x: auto; max-width: 600px; }
@media (max-width: 640px) { .certificate-preview .letter-paper { padding: 12px; } }
.legacy-totals .alarm { color: #b91c1c; font-weight: 500; }
html.dark .legacy-totals .alarm { color: #fca5a5; }
/* ссылки в списках справок: номер документа, клиент, «Просили», скан — видно, что нажимаются */
.wht-link { color: var(--brand-strong); }
.wht-link:hover { text-decoration: underline; }
html.dark .wht-link { color: #b892f2; }

/* Импорт выписки: галки RE и писем и пояснение к «Already recorded» (31.10.2026) */
.bank-new-payments { display: contents; }
.bank-new-payments[hidden] { display: none; }
.bank-link-note { flex-basis: 100%; margin: 0; font-size: 13px; text-align: right; }

/* --- «Cash flow» — учёт денег (admin_cashflow.py, 29.10.2026) --- */
.cash-amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.cash-in, .cash-plus { color: #15803d; }
.cash-minus { color: #b91c1c; }
html.dark .cash-in, html.dark .cash-plus { color: #4ade80; }
html.dark .cash-minus { color: #fca5a5; }
.cash-hint { font-size: 12px; opacity: .65; margin-top: 2px; }
/* «Payments»: вкладки и строка поставщика над его платежами (18.11.2026) */
.doc-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.doc-tab { padding: .3rem .75rem; border: 1px solid var(--card-line); border-radius: 999px; font-size: 13.5px;
  white-space: nowrap; }
.doc-tab b { margin-left: .2rem; font-weight: 600; }
.doc-tab:hover { border-color: var(--brand); }
.doc-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pay-group td { padding: .65rem .85rem .45rem; border-top: 1px solid var(--card-line); }
.pay-group-name { font-weight: 600; }
a.pay-group-name:hover { color: var(--brand); text-decoration: underline; }
.pay-group-sum { display: inline-block; margin-left: .75rem; font-size: 13px; opacity: .7; }
@media (max-width: 767px) {
  .pay-group-sum { display: block; margin-left: 0; }
}
.cash-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cash-filter select { border: 1px solid var(--card-line); border-radius: .5rem; padding: .4rem .6rem;
  background: transparent; color: inherit; font-size: 13.5px; }
.cash-scroll { overflow-x: auto; margin-top: 8px; }
.cash-table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.cash-table th, .cash-table td { padding: 6px 10px; border-bottom: 1px solid var(--card-line); }
.cash-table thead th { font-weight: 500; font-size: 12.5px; opacity: .7; white-space: nowrap; }
/* название категории остаётся на месте, когда месяцы листают вбок */
.cash-table tbody th { text-align: left; font-weight: 400; white-space: nowrap; position: sticky; left: 0;
  background: var(--card); }
.cash-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cash-table td a { color: inherit; }
.cash-table td a:hover { color: var(--brand-strong); text-decoration: underline; }
.cash-section th { font-weight: 600; font-size: 13px; padding-top: 18px; border-bottom: 2px solid var(--card-line); }
.cash-sum th, .cash-sum td { font-weight: 600; }
.cash-net th, .cash-net td { font-weight: 700; border-top: 2px solid var(--card-line); border-bottom: 0; }
.cash-total { min-width: 120px; }
.cash-bar { display: block; height: 4px; margin: 0 0 3px auto; border-radius: 2px; background: var(--brand-strong);
  opacity: .3; }
.cash-bar-owner { background: #d97706; }
.cash-foot { margin-top: 10px; }
.cash-sort { border: 1px solid var(--card-line); border-radius: .75rem; padding: 10px 14px; margin: 0 0 10px; }
.cash-sort-head { display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.cash-sort-sum { text-align: right; }
.cash-sort .muted { opacity: .65; font-size: 12.5px; }
.cash-sort .strong { font-weight: 600; }
.cash-sort-fields { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.cash-sort-fields select, .cash-sort-fields input[type=text] { border: 1px solid var(--card-line); border-radius: .5rem;
  padding: .45rem .6rem; background: transparent; color: inherit; font-size: 13.5px; flex: 1 1 200px; min-width: 0; }
@media (max-width: 640px) { .cash-sort-sum { text-align: left; } }

/* Закрывающие документы поставщиков (admin_supplier_docs.py, 31.10.2026) */
.sdoc-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--card-line);
  vertical-align: middle; background: var(--card); }
.sdoc-thumb-big { width: 96px; height: 120px; }
.sdoc-inbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 0 0 14px; }
.sdoc-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--card-line);
  border-radius: .5rem; cursor: pointer; }
.sdoc-option:has(input:checked) { border-color: var(--brand-strong); box-shadow: 0 0 0 1px var(--brand-strong); }
.sdoc-option input { accent-color: var(--brand-strong); margin-top: 4px; flex: none; }
.sdoc-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.sdoc-file { display: inline-block; padding: .4rem .5rem; border: 1px dashed var(--card-line); border-radius: 6px;
  font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdoc-meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.sdoc-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; padding: 10px 12px; margin: 8px 0;
  border: 1px solid var(--card-line); border-radius: .5rem; max-height: 320px; overflow: auto; }
.sdoc-pages-big { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.sdoc-page { display: block; max-height: 560px; max-width: min(100%, 520px); border: 1px solid var(--card-line);
  border-radius: 8px; background: #fff; }
.sdoc-file-big { max-width: none; padding: .8rem 1rem; font-size: 14px; }

/* --- Кнопка у пункта бокового меню: «Import PDF» справа от «Quotations»
   (владелец, 06.11.2026: «перенеси пожалуйста кнопку импорт pdf вот сюда»;
   разметка — templates/unfold/helpers/app_list.html, пункт — "action" в
   UNFOLD["SIDEBAR"]) --- */
.nav-item-with-action { position: relative; }
.nav-item-with-action > a:first-child { padding-right: 8.5rem; }
.nav-item-action {
  position: absolute; right: -0.25rem; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 0.25rem;
  height: 26px; padding: 0 0.6rem;
  border: 1px solid var(--card-line); border-radius: 999px;
  background: var(--card); color: var(--brand-strong);
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.nav-item-action .material-symbols-outlined { font-size: 16px; }
.nav-item-action:hover { border-color: var(--brand); background: var(--brand); color: #fff; }
.nav-item-action:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html.dark .nav-item-action { color: #c9a9f7; }
html.dark .nav-item-action:hover { color: #fff; }

/* Действие выполняется (submit_once.js, 19.11.2026): кнопка и полоса сверху */
.df-busy-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 10000; display: flex; gap: .6rem;
  align-items: center; justify-content: center; padding: .65rem 1rem; background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 500; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.df-busy-bar[hidden] { display: none; }
.df-busy { cursor: progress !important; opacity: .85; }
.df-spin { display: inline-block; width: 1em; height: 1em; margin-right: .45em; vertical-align: -.15em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: df-spin .8s linear infinite; }
.df-busy-bar .df-spin { margin-right: 0; }
@keyframes df-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .df-spin { animation-duration: 2.4s; } }

/* --- Окно «Company details» у логотипа (company_details.html, company_details.js, 26.11.2026) ---
   Окно скрипт переносит в конец страницы: боковое меню обрезало бы окно шире себя. */
.company-details-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; margin-left: 2px; border-radius: 8px;
  color: rgb(107 114 128); background: transparent; cursor: pointer;
}
.company-details-toggle:hover,
.company-details-toggle[aria-expanded="true"] { color: var(--brand-strong); background: rgba(142, 84, 230, 0.1); }
.company-details-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html.dark .company-details-toggle { color: rgb(156 163 175); }
html.dark .company-details-toggle:hover,
html.dark .company-details-toggle[aria-expanded="true"] { color: #c4a5f5; background: rgba(170, 124, 239, 0.14); }

.company-details {
  position: fixed; z-index: 70; box-sizing: border-box; overflow-y: auto;
  padding: 10px 8px 8px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--card-line);
  box-shadow: 0 2px 6px rgba(24, 16, 48, 0.08), 0 18px 44px rgba(24, 16, 48, 0.18);
  font-size: 13px; line-height: 1.35; color: rgb(55 65 81);
}
.company-details[hidden] { display: none; }
html.dark .company-details { color: rgb(209 213 219); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6); }
.company-details-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px 8px;
}
.company-details-title { font-weight: 600; font-size: 14px; color: rgb(17 24 39); }
html.dark .company-details-title { color: #fff; }
.company-copy-all {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 8px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 12px; cursor: pointer;
}
.company-copy-all:hover { background: var(--brand-strong); }
.company-copy-all:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.company-copy-all .material-symbols-outlined { font-size: 16px; }
.company-copy-all.is-copied { background: #15803d; }
.company-details-rows { list-style: none; margin: 0; padding: 0; }
/* подпись слева, значение справа — все реквизиты и оба счёта помещаются без прокрутки */
.company-row {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) 18px; column-gap: 10px; align-items: baseline;
  width: 100%; padding: 4px 6px; border-radius: 8px; text-align: left; background: transparent; color: inherit;
  cursor: pointer;
}
.company-row:hover { background: rgba(142, 84, 230, 0.07); }
html.dark .company-row:hover { background: rgba(170, 124, 239, 0.1); }
.company-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.company-row-label { grid-column: 1; font-size: 12px; color: rgb(107 114 128); }
.company-row-value { grid-column: 2; color: rgb(17 24 39); overflow-wrap: anywhere; }
html.dark .company-row-label { color: rgb(156 163 175); }
html.dark .company-row-value { color: #f3f4f6; }
.company-row-icon {
  grid-column: 3; grid-row: 1; align-self: center;
  font-size: 16px !important; color: var(--brand); opacity: 0; transition: opacity 0.12s;
}
.company-row:hover .company-row-icon,
.company-row:focus-visible .company-row-icon,
.company-row.is-copied .company-row-icon,
.company-row.is-failed .company-row-icon { opacity: 1; }
.company-row.is-copied .company-row-icon { color: #15803d; }
.company-row.is-failed .company-row-icon { color: #dc2626; }
html.dark .company-row.is-copied .company-row-icon { color: #4ade80; }
.company-details-sub {
  margin: 6px 6px 2px; padding-top: 9px; border-top: 1px solid var(--card-line);
  font-size: 12px; font-weight: 600; color: rgb(75 85 99);
}
html.dark .company-details-sub { color: rgb(156 163 175); }
.company-details-foot {
  display: flex; align-items: center; gap: 12px; margin: 6px 0 0; padding: 8px 6px 2px;
  border-top: 1px solid var(--card-line); font-size: 12px;
}
.company-details-note { color: #15803d; }
.company-details-note.is-failed { color: #dc2626; }
html.dark .company-details-note { color: #4ade80; }
html.dark .company-details-note.is-failed { color: #f87171; }
.company-details-foot a { margin-left: auto; color: var(--brand-strong); white-space: nowrap; }
.company-details-foot a:hover { text-decoration: underline; }
html.dark .company-details-foot a { color: #c4a5f5; }
@media (prefers-reduced-motion: reduce) { .company-row-icon { transition: none; } }
