/* Мини-апп «кабинет клиента»: цвета только из themeParams Telegram (светлая/тёмная сами) */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #808080);
  --link: var(--tg-theme-link-color, #2678b6);
  --btn: var(--tg-theme-button-color, #2678b6);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #2678b6));
  --danger: var(--tg-theme-destructive-text-color, #d33);
}
* { box-sizing: border-box; margin: 0; }

/* ФИКС двойного экрана: атрибут hidden обязан побеждать любые display из этого файла
   (без этого #login-screen{display:flex} и .btn{display:block} показывали скрытое) */
[hidden] { display: none !important; }
/* 07-30 (жалоба юзера: «до последней строки любой вкладки почти нереально
   дотянуться»): height:100% запирал документ в высоту вьюпорта — хвост
   контента оказывался за нижней панелью и не доскролливался. min-height
   держит фон на весь экран, но позволяет странице расти. */
html { height: 100%; }
body {
  min-height: 100%;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  /* панель вкладок (56) + плавающая кнопка над ней (28) + воздух */
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}
main { padding: 14px 14px 8px; max-width: 640px; margin: 0 auto; }
h2 { font-size: 17px; margin: 18px 0 10px; }
.center { text-align: center; padding: 40px 16px; color: var(--hint); }

.card {
  background: var(--bg2); border-radius: 14px; padding: 14px; margin-bottom: 10px;
}
.card .big { font-size: 18px; font-weight: 600; }
.muted { color: var(--hint); font-size: 13px; }
.status-ok { color: var(--accent); }
.status-warn, .status-expired { color: var(--danger); font-weight: 600; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--btn); color: var(--btn-text);
  font-size: 15px; font-weight: 600; padding: 12px; margin: 10px 0;
}
.btn.ghost { background: transparent; color: var(--link); border: 1px solid var(--link); }
.btn[disabled] { opacity: .55; }
a.btn { text-align: center; text-decoration: none; }

/* тарифы */
.tariff {
  background: var(--bg2); border: 2px solid transparent; border-radius: 14px;
  padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.tariff.featured { border-color: var(--btn); }
.tariff.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tariff .price { font-size: 19px; font-weight: 700; margin-top: 2px; }
.tariff ul { margin: 8px 0 0 18px; padding: 0; font-size: 13px; color: var(--hint); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: var(--btn); color: var(--btn-text); margin-left: 6px;
}

/* оплата: на мобильном обёртки прозрачны (display:contents), порядок блоков — как был */
#tab-pay { display: flex; flex-direction: column; }
#pay-left, #pay-right { display: contents; }
#pay-status-block { order: 1; }
#pay-pending { order: 2; }
#tariffs-title { order: 3; }
#tariff-cards { order: 4; }
#pay-block { order: 5; }
#pay-history { order: 6; }
/* во flex поля заголовков не схлопываются с карточками — компенсируем до прежних 18px */
#tab-pay h2 { margin-top: 8px; }

#pay-block .req { margin: 6px 0; }
#pay-block img.qr { display: block; max-width: 240px; width: 100%; margin: 10px auto; border-radius: 12px; }
.pending-banner {
  background: var(--bg2); border-left: 4px solid var(--btn);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}

/* история платежей */
table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist td { padding: 6px 4px; border-top: 1px solid var(--bg2); }
table.hist td:last-child { text-align: right; white-space: nowrap; }

/* документы */
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--hint); background: transparent; color: var(--text);
  border-radius: 20px; padding: 5px 13px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--btn); border-color: var(--btn); color: var(--btn-text); }
/* Свайп-удаление строки журнала */
.doc-swipe { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 8px; }
.doc-swipe.removing { max-height: 0 !important; margin-bottom: 0; opacity: 0; transition: max-height .2s ease, opacity .2s ease, margin .2s ease; }
.doc-swipe .doc-row { margin-bottom: 0; position: relative; z-index: 1; touch-action: pan-y; transition: transform .2s ease; will-change: transform; }
.doc-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 88px; z-index: 0;
  border: 0; background: #e5484d; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
/* Подтверждение да/нет */
.confirm-ov { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.confirm-box { background: var(--bg2); color: var(--text); border-radius: 16px; padding: 20px; max-width: 340px; width: 100%; max-height: 85vh; overflow-y: auto; }
.confirm-box p { margin: 0 0 16px; white-space: pre-line; font-size: 15px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }
/* 07-28: длинные списки вариантов (план счетов, статьи) — вертикально и со своим скроллом.
   Раньше 20 кнопок с flex:1 в flex-wrap крошили текст по слогам и вылезали за экран. */
.dlg-list { max-height: 45vh; overflow-y: auto; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.dlg-list .btn.dlg-item { margin: 0; width: 100%; text-align: left; font-weight: 500; font-size: 14px; line-height: 1.35; padding: 10px 12px; }
/* статусный оверлей: спиннер на время долгих операций (правка/проведение — до минуты) */
.busy-spin { width: 28px; height: 28px; border: 3px solid var(--hint); border-top-color: var(--text); border-radius: 50%; animation: busyspin .8s linear infinite; margin: 0 auto 12px; }
@keyframes busyspin { to { transform: rotate(360deg); } }

.doc-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.doc-row .info { flex: 1; min-width: 0; }
.doc-row .t { font-weight: 600; font-size: 14px; }
.doc-row .s { color: var(--hint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row button {
  border: 0; background: transparent; font-size: 20px; cursor: pointer; padding: 6px;
}
.note { color: var(--hint); font-size: 12px; margin: 14px 4px 6px; text-align: center; }

/* форма поддержки */
#support-form textarea {
  width: 100%; border: 1px solid var(--hint); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; padding: 10px; resize: vertical;
}
#support-form .btn { margin-bottom: 0; }

/* переключатель тенантов */
select#tenant-sel {
  width: 100%; padding: 10px; border-radius: 10px; margin-bottom: 12px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--hint); font-size: 15px;
}

/* нижние вкладки */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--bg2); border-top: 1px solid rgba(128,128,128,.25);
  padding-bottom: env(safe-area-inset-bottom);
  /* 07-27 (жалоба юзера): вкладки уезжали ПОД содержимое — при длинном списке
     документов до них было не дотянуться, пока не долистаешь до конца.
     Фиксация без z-index не спасает: карточки и липкие блоки рисуются поверх. */
  z-index: 60;
}
#tabs button {
  flex: 1; border: 0; background: transparent; color: var(--hint);
  font-size: 19px; padding: 7px 0 5px; cursor: pointer;
}
#tabs button span { display: block; font-size: 11px; margin-top: 1px; }
#tabs button.active { color: var(--btn); }

#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 14px;
  padding: 9px 16px; border-radius: 22px; max-width: 88%; z-index: 80;
}

/* экран входа (браузерный режим) */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box { max-width: 380px; text-align: center; }
.login-logo { font-size: 34px; font-weight: 800; margin-bottom: 10px; }
.login-logo span { color: var(--btn); }
.login-box h1 { font-size: 21px; margin-bottom: 10px; }
.login-box p { margin-bottom: 10px; }
#login-widget { margin-top: 18px; display: flex; justify-content: center; min-height: 46px; }

/* верхняя панель (десктоп, только браузерный режим) */
#topbar {
  display: none; align-items: center; gap: 20px;
  padding: 12px 24px; background: var(--bg2);
  border-bottom: 1px solid rgba(128,128,128,.25);
  position: sticky; top: 0; z-index: 5;
}
#topbar .tb-logo { font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; }
#topbar .tb-logo span { color: var(--btn); }
#topbar nav { display: flex; gap: 6px; flex: 1; }
#topbar nav button {
  border: 0; background: transparent; color: var(--hint);
  font-size: 15px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
#topbar nav button.active { background: var(--btn); color: var(--btn-text); }
#logout-top {
  border: 1px solid var(--hint); background: transparent; color: var(--text);
  border-radius: 10px; padding: 7px 16px; cursor: pointer; font-size: 14px;
}
body.state-login #topbar { display: none !important; }   /* на экране входа — ничего лишнего */

/* десктоп ≥900px, только браузерный режим (мини-апп и мобильный вид не трогаем) */
@media (min-width: 900px) {
  body.mode-web { padding-bottom: 24px; }
  body.mode-web #topbar { display: flex; }
  body.mode-web #tabs { display: none; }
  body.mode-web main { max-width: 880px; padding: 24px 20px; }
  body.mode-web #tab-pay { flex-direction: row; gap: 26px; align-items: flex-start; }
  body.mode-web #pay-left, body.mode-web #pay-right { display: block; flex: 1 1 0; min-width: 0; }
  body.mode-web #tariffs-title { margin-top: 0; }
  body.mode-web .login-box { background: var(--bg2); border-radius: 16px; padding: 34px 38px; }
}

/* ═══ очередь 2: форма создания документа ═══ */
.docs-head { margin-bottom: 10px; }
.docs-head .btn { margin: 0; }
/* когда форма открыта — список/фильтры прячем, показываем только форму */
#tab-docs.form-open .docs-head,
#tab-docs.form-open #doc-filters,
#tab-docs.form-open #doc-list,
#tab-docs.form-open #doc-more,
#tab-docs.form-open #doc-note { display: none; }

.doc-form .df-head { display: flex; align-items: center; gap: 10px; }
.doc-form .df-head h2 { flex: 1; margin: 0; }
.df-close { border: 0; background: transparent; color: var(--hint); font-size: 18px; cursor: pointer; padding: 4px 8px; }

.fld { margin: 10px 0; }
.fld > label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 4px; }
.fld input, .fld select, .knp select, .knp-free {
  width: 100%; padding: 10px; border-radius: 10px; font: inherit;
  background: var(--bg); color: var(--text); border: 1px solid var(--hint);
}
.knp { display: flex; gap: 6px; }
.knp select { flex: 1; }
.knp-free { max-width: 110px; }

/* автодополнение */
.ref { position: relative; }
.ac-drop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: var(--bg); border: 1px solid var(--hint); border-radius: 10px;
  margin-top: 3px; max-height: 220px; overflow-y: auto; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.ac-item { padding: 9px 11px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--bg2); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover { background: var(--bg2); }
.ac-empty { padding: 9px 11px; color: var(--hint); font-size: 13px; }

/* строки табчасти */
.rows { margin: 14px 0 6px; }
.rows-h { font-size: 13px; color: var(--hint); margin-bottom: 6px; }
/* строка позиции — ДВЕ подстроки: сверху номенклатура во всю ширину, снизу числа + ✕ */
.row-line { margin-bottom: 12px; }
.row-line .ref { display: block; min-width: 0; }     /* номенклатура — вся ширина; дропдаун раскрывается под ней */
.rl-nums {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;            /* кол-во | цена | сумма | ✕ (три числовых равны) */
  column-gap: 6px;
  align-items: center;
  margin-top: 6px;
}
/* Номенклатура (.ref input) и три числовых (.rl-n) — ОДИН стиль: фон/рамка/радиус/высота/
   паддинг/шрифт/цвет совпадают; отличие только в ширине и выравнивании чисел вправо.
   Снимаем дефолтный вид input (в т.ч. спиннеры number), чтобы поля были неотличимы. */
.row-line .ref input,
.rl-nums .rl-n {
  width: 100%; min-width: 0; box-sizing: border-box;
  height: 38px; padding: 0 8px; margin: 0;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--hint); border-radius: 9px;
  -webkit-appearance: none; -moz-appearance: textfield; appearance: none;
}
.row-line .ref input::placeholder,
.rl-nums .rl-n::placeholder { color: var(--hint); opacity: 1; }
.rl-nums .rl-n::-webkit-outer-spin-button,
.rl-nums .rl-n::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rl-nums .rl-n { text-align: right; }                /* числа — вправо (не влияет на фон/рамку/высоту) */

.rl-del {
  justify-self: end; box-sizing: border-box;
  border: 0; background: transparent; color: var(--danger);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 8px 6px;
}
.btn.ghost.sm { display: inline-block; width: auto; padding: 7px 14px; margin: 2px 0 0; font-size: 13px; }
.rows-total { text-align: right; font-weight: 700; margin-top: 8px; }

.df-actions { margin-top: 14px; }
.df-actions .btn { margin: 8px 0 0; }
.df-err { color: var(--danger); font-size: 13px; margin-top: 10px; }
.df-err.show { background: var(--bg); border: 1px solid var(--danger); border-radius: 10px; padding: 9px 11px; }
.df-err div { margin: 2px 0; }

/* ═══ карточка чтения документа (модалка) ═══ */
.doc-row { cursor: pointer; }
.doc-chevron { flex: 0 0 auto; color: var(--hint); font-size: 22px; line-height: 1; padding: 0 2px; }

.mc-backdrop {
  /* выше вкладок (60): затемнение модалки должно накрывать и панель вкладок */
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px; overflow-y: auto;
}
.mc {
  background: var(--bg); color: var(--text); border-radius: 16px;
  width: 100%; max-width: 460px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  overflow: hidden;
}
.mc-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 6px; }
.mc-head h2 { flex: 1; margin: 0; font-size: 16px; }
.mc-x { border: 0; background: transparent; color: var(--hint); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.mc-body { padding: 6px 14px 14px; }
.mc-fields { margin-bottom: 10px; }
.mc-f { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--bg2); font-size: 14px; }
.mc-f span { color: var(--hint); flex: 0 0 40%; }
.mc-f b { flex: 1; font-weight: 600; word-break: break-word; }
.mc-pos { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.mc-pos th { text-align: right; color: var(--hint); font-weight: 500; padding: 5px 4px; border-bottom: 1px solid var(--bg2); }
.mc-pos th:first-child, .mc-pos td:first-child { text-align: left; }
.mc-pos td { padding: 6px 4px; border-bottom: 1px solid var(--bg2); text-align: right; vertical-align: top; }
.mc-actions { margin-top: 14px; }
.mc-actions .btn { margin: 8px 0 0; }

/* Проводки Дт/Кт (только у проведённого документа; данные — op16) */
.mc-sec { margin-top: 14px; }
.mc-sec-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-sec-h .mc-add { font-size: 12px; padding: 4px 10px; text-transform: none; letter-spacing: 0; }
.mc-empty { font-size: 13px; color: var(--hint); padding: 6px 0; }
.mc-pr { width: 100%; border-collapse: collapse; font-size: 13px; }
.mc-pr td { padding: 7px 4px; border-bottom: 1px solid var(--bg2); vertical-align: top; }
.mc-pr .pr-dt, .mc-pr .pr-kt { white-space: nowrap; }
.mc-pr .pr-dt b, .mc-pr .pr-kt b { display: block; font-weight: 700; font-variant-numeric: tabular-nums; }
.mc-pr .pr-dt i, .mc-pr .pr-kt i {
  display: block; font-style: normal; font-size: 11px; color: var(--hint);
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mc-pr .pr-ar { color: var(--hint); text-align: center; width: 18px; }
.mc-pr .pr-sum { text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mc-pr .pr-note td { border-bottom: 1px solid var(--bg2); padding: 0 4px 7px; font-size: 12px; color: var(--hint); }
.mc-nu { margin-top: 8px; }
.mc-nu summary { cursor: pointer; font-size: 12px; color: var(--hint); padding: 4px 0; }
.mc-nu[open] summary { margin-bottom: 4px; }

/* браузер без themeParams: уважаем системную тёмную тему (в Telegram
   inline-переменные themeParams переопределяют эти фолбэки) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #181a1d);
    --bg2: var(--tg-theme-secondary-bg-color, #25282c);
    --text: var(--tg-theme-text-color, #e8e8e8);
    --hint: var(--tg-theme-hint-color, #9a9a9a);
  }
}

/* ═══════════ СВОДКА (дашборд) ═══════════
   Цвета — только токены темы Telegram (светлая/тёмная сама).
   Динамика: рост/спад — единственные семантические цвета, берём из токенов TG. */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--bg2); border-radius: 14px; padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kpi-t { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--hint); }
.kpi-i { font-size: 14px; line-height: 1; }
.kpi-v {
  font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; word-break: break-word;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.kpi-h { font-size: 11px; color: var(--hint); }
.kpi-d { font-size: 12px; font-weight: 600; white-space: nowrap; }
.kpi-d.up { color: var(--tg-theme-accent-text-color, #1a9e4b); }
.kpi-d.down { color: var(--danger); }

.dash-card { margin-bottom: 12px; }
.dash-card.accent { border: 1px solid var(--bg2); box-shadow: inset 3px 0 0 var(--accent); }
.dash-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin-bottom: 10px; }
.dash-empty { font-size: 13px; color: var(--hint); padding: 8px 0; }
.dash-more { font-size: 12px; color: var(--hint); padding: 6px 0 2px; }
.dash-foot { text-align: center; font-size: 11px; color: var(--hint); padding: 4px 0 12px; }
/* Отметка «данные на HH:MM» + ручное обновление. Витрина сначала рисует снапшот,
   поэтому время сборки должно быть видно — иначе цифры выглядят свежее, чем они есть. */
.foot-refresh {
  background: none; border: 0; color: var(--hint); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 4px; vertical-align: middle;
}
.foot-refresh:active { color: var(--accent); }
.foot-busy { color: var(--hint); opacity: .75; }

/* мини-график: столбики на div, без библиотек */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 96px; padding-top: 4px; }
.bars .bar {
  flex: 1 1 0; min-width: 6px; background: var(--accent); border-radius: 4px 4px 2px 2px;
  opacity: .85; position: relative; display: flex; justify-content: center;
}
.bars .bar:hover { opacity: 1; }
.bars .bar span {
  position: absolute; bottom: -16px; font-size: 9px; color: var(--hint);
}

/* список должников */
.dlist { display: flex; flex-direction: column; }
.dl-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bg2); }
.dl-row:last-child { border-bottom: 0; }
.dl-n { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-s { font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 1С офлайн */
.dash-off { text-align: center; padding: 24px 16px; }
.dash-off-i { font-size: 28px; margin-bottom: 8px; }
.dash-off b { display: block; margin-bottom: 6px; }
.dash-off .btn { margin-top: 12px; }

/* скелетон загрузки */
.dash-skel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dash-skel div { height: 78px; border-radius: 14px; background: var(--bg2); animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { 0%,100% { opacity: .55; } 50% { opacity: .95; } }

@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .bars { height: 128px; }
}

/* Учётные счета строки (форма Реализации): из памяти — свёрнуто, иначе селекты */
.rl-acc { grid-column: 1 / -1; margin-top: 6px; }
.rl-acc-h { font-size: 12px; color: var(--hint); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rl-acc-edit { border: 0; background: transparent; color: var(--link); font-size: 12px; cursor: pointer; padding: 0; }
.rl-acc-f { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.rl-acc-f label { font-size: 11px; color: var(--hint); }
.rl-acc-f select {
  width: 100%; padding: 8px; border-radius: 8px; font-size: 13px;
  background: var(--bg); color: var(--text); border: 1px solid var(--hint);
}

/* ─── ОТЧЁТЫ ───────────────────────────────────────────────────────
   Таблицы бухотчётов широкие (ОСВ = 8 колонок) — скроллим ТОЛЬКО таблицу,
   страница по горизонтали ехать не должна. */
.filters { flex-wrap: wrap; }
.rep-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px;
}
.rep-controls .btn { width: auto; padding: 8px 16px; margin: 0; }
.rep-dates, .rep-acc { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--hint); }
.rep-dates input, .rep-acc select {
  background: var(--bg2); color: var(--text); border: 1px solid var(--bg2);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; font-family: inherit;
}
.rep-acc select { max-width: 210px; }
.rep-h { font-size: 16px; font-weight: 600; margin: 4px 0 2px; }
.rep-sub { font-size: 12px; color: var(--hint); margin-bottom: 10px; }
.rep-open { font-size: 13px; margin-bottom: 8px; }
.rep-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; background: var(--bg2); }
.rep-table { border-collapse: collapse; font-size: 13px; width: 100%; min-width: 640px; }
.rep-table th, .rep-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--bg); text-align: left; white-space: nowrap;
}
.rep-table th { font-weight: 600; font-size: 12px; color: var(--hint); position: sticky; top: 0; background: var(--bg2); }
.rep-table td.num, .rep-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rep-table tbody tr:hover td { background: rgba(127, 127, 127, .07); }
.rep-table tr.rep-total td { font-weight: 700; border-top: 2px solid var(--hint); border-bottom: none; }

/* Отбор счетов в ОСВ */
.rep-accf { margin-bottom: 12px; position: relative; }
.chip.sm { padding: 5px 10px; font-size: 12px; }
.rep-accf-panel {
  margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--bg2);
}
.rep-accf-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rep-accf-list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; }
.rep-accf-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  font-size: 13px; border-radius: 8px; cursor: pointer;
}
.rep-accf-item:hover { background: rgba(127, 127, 127, .08); }
.rep-accf-item input { width: 16px; height: 16px; flex: none; }
.rep-accf-item b { flex: none; font-variant-numeric: tabular-nums; }
.rep-accf-item span { color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-accf-foot { display: flex; gap: 8px; margin-top: 10px; }
.rep-accf-foot .btn { width: auto; margin: 0; }
.btn.sm { padding: 7px 14px; font-size: 13px; width: auto; }
.rep-accf-search {
  width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 8px 10px;
  background: var(--bg); color: var(--text); border: 1px solid var(--bg);
  border-radius: 8px; font-size: 13px; font-family: inherit;
}
.rep-accf-item span.wide { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

/* Акт сверки: кнопка «создать документ в 1С» в строке отчёта.
   Узкая колонка справа; на «—» (движения без контрагента) кнопки нет — там пустая ячейка. */
.rep-table th.rep-act-h,
.rep-table td.rep-act { width: 40px; padding: 0 4px; text-align: center; }
.rep-act-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 7px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.rep-act-btn:hover { border-color: var(--accent); }
.rep-act-btn:disabled { opacity: .5; cursor: default; }

/* ─── фаза 2-А: справочники (экран замещает журнал документов) ─── */
.docs-head { display: flex; gap: 8px; }
.docs-head .btn { flex: 1; }
#tab-docs.refs-open .docs-head,
#tab-docs.refs-open #doc-filters,
#tab-docs.refs-open #doc-list,
#tab-docs.refs-open #doc-more,
#tab-docs.refs-open #doc-note { display: none; }
#refs-back { display: inline-block; width: auto; padding: 8px 14px; margin: 0 0 10px; }
.refs-search {
  width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 10px 12px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--bg2);
  border-radius: 10px; font-size: 14px; font-family: inherit;
}

/* ── этап 16 (хвост): журнал «дел» (controls) на дашборде ── */
/* 19.08: кнопки «плыли» на узких экранах — текст без min-width:0 выдавливал кнопки
   за границу карточки. Теперь текст сжимается/обрезается, кнопки фиксированы.
   Плюс свайп-жест (влево ⏰ / вправо ✓) и сворачивание блока. */
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line);
  position: relative; overflow: hidden; touch-action: pan-y; transition: transform .15s ease, background .15s ease; border-radius: 8px; }
.ctl-row:first-of-type { border-top: none; }
.ctl-txt { font-size: 13px; line-height: 1.35; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ctl-txt .muted { display: block; font-size: 12px; }
.ctl-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.ctl-btns .btn { flex: 0 0 auto; width: 38px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ctl-row.swipe-left  { background: color-mix(in srgb, orange 18%, transparent); }
.ctl-row.swipe-right { background: color-mix(in srgb, #22c55e 18%, transparent); }
.ctl-head { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; }
.ctl-head .chev { transition: transform .15s ease; }
.ctl-collapsed .chev { transform: rotate(-90deg); }
.ctl-hint { font-size: 11px; }
.ctl-done, .ctl-snooze { min-width: 40px; width: 40px; height: 40px; padding: 0; font-size: 18px; line-height: 38px; border-radius: 10px; }


/* 07-27: панель обновления сводки — внизу, во всю ширину, НАД вкладками.
   Сначала она жила в подвале длинной страницы: на телефоне до неё приходилось
   листать четыре экрана, а перерисовка сбрасывала скролл наверх. Теперь она
   закреплена и не зависит от прокрутки, но и вкладки собой не закрывает. */
.dash-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom));   /* ровно над панелью вкладок */
  z-index: 40;                                        /* ниже вкладок (60) */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 1px solid rgba(128,128,128,.18);
}
.dash-bar-when {
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
}
.dash-bar-when.busy { opacity: .75; }
.dash-bar-refresh {
  flex: 1;                    /* во всю оставшуюся ширину — попасть пальцем легко */
  min-height: 48px;
  border-radius: 12px;
  border: 0;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.dash-bar-refresh:active { opacity: .85; }

/* Хвост сводки не должен прятаться за двумя нижними панелями */
#tab-dash { padding-bottom: 76px; }
/* …и хвост любой другой вкладки тоже (жалоба юзера 07-30) */
main > .tab { padding-bottom: 24px; }

/* 28.08: универсальная форма (meta-form): строка табличной части — ячейки по колонкам */
.mf-row { display:flex; flex-wrap:wrap; gap:6px; align-items:center; padding:6px 0; border-bottom:1px solid var(--bg2); }
.mf-row .ref.mf-cell { flex:1 1 180px; min-width:140px; }
.mf-row input.mf-cell { flex:1 1 90px; min-width:70px; padding:8px; border-radius:10px; border:1px solid var(--hint); background:var(--bg2); color:var(--text); }
.mf-row label.mf-check { display:flex; align-items:center; gap:4px; font-size:13px; }
.mf-row .rl-del { flex:0 0 auto; }
.mf-c { display:flex; flex-direction:column; gap:2px; flex:1 1 100px; min-width:84px; }
.mf-c.mf-c-ref { flex:2 1 200px; min-width:160px; }
.mf-c-ro small { opacity:.7; }
.mf-row input.mf-ro { background:transparent; border-style:dashed; color:var(--hint); }
.mf-all { color:var(--accent, #2a7fd4); text-decoration:none; font-size:11px; margin-left:4px; cursor:pointer; }
.mf-c small { font-size:11px; color:var(--hint); line-height:1.1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mf-c > input.mf-cell, .mf-c > select, .mf-c > .ref.mf-cell { width:100%; min-width:0; flex:none; }

/* 01.09: группа выписки, по которой у бота нет решения. Раньше это была мелкая серая
   строчка внутри карточки — её просто не замечали. Теперь видно сразу. */
.ctl-row.br-row-unknown{ border:1px solid var(--danger); border-radius:10px; padding:8px;
  background:rgba(211,51,51,.07); }
.br-unknown{ margin-top:6px; padding:7px 9px; border-radius:8px;
  border-left:3px solid var(--danger); background:rgba(211,51,51,.10); font-size:12.5px; }
.br-unknown b{ color:var(--danger); }

/* 01.09: удержание эквайрера — не самостоятельная операция, а часть продаж своего дня */
.br-fee{ margin-top:6px; padding:7px 9px; border-radius:8px; border-left:3px solid var(--accent);
  background:var(--bg2); font-size:12.5px; }
