/* Визуальная чистка раздела (аудит 28.09.2026). Подключается после visual-polish.css. */
/* Каждая страница «Учёта и финансов» / «Экономики» ставит в начало контента
   маркер <i class="fm-mark fm-…" hidden>; всё ниже привязано к нему через
   body:has(…), чтобы не задеть другие разделы. */

/* ---------- Общее для раздела ---------- */

/* Вкладки «Экономики» и «Финансового учёта»: все в одну строку на 1440 */
body.pusk-generic .pusk-ws-tabs:is([aria-label="Экономика"], [aria-label="Финансовый учёт"]) { gap: 4px 12px; }
body.pusk-generic .pusk-ws-tabs:is([aria-label="Экономика"], [aria-label="Финансовый учёт"]) a { font-size: 13px !important; }

/* Кнопка фильтра («Найти», «Показать») — везде основная, бирюзовая */
body:has(.fm-mark) .pusk-generic-pane form[method=get] button:not(.ghost):not(.del):not(.mini):not(.link-btn):not(.tickbox),
body:has(.fm-mark) .pusk-generic-pane form.fm-filter button:not(.ghost):not(.del):not(.mini):not(.link-btn) {
  background: var(--accent) !important;
  color: var(--card) !important;
  border-color: transparent !important;
  box-shadow: var(--sh-accent);
}

/* Ноль в карточке-итоге не красим */
:root body:has(.fm-mark) :is(.box, .card).zero :is(.box-num, .num),
:root body:has(.fm-mark) :is(.box, .card).zero.zero :is(.box-num, .num) {
  color: var(--text-primary, var(--ink)) !important;
}
:root body:has(.fm-mark) .pusk-generic-pane :is(.box, .card).zero :is(.box-num, .num) {
  color: var(--text-primary, var(--ink)) !important;
}

/* Галочка «выполнено» — квадрат 20×20, одинаковый на сводке и в календаре */
body:has(.fm-mark) .pusk-generic-pane button.tickbox {
  width: 20px !important; height: 20px !important;
  min-width: 20px !important; min-height: 20px !important;
  padding: 0 !important; flex: 0 0 20px;
}

/* Кнопка выбора файла: label поверх скрытого input */
body:has(.fm-mark) label.fm-file {
  position: relative; display: inline-flex !important; align-items: center;
  height: 36px; padding: 0 12px !important; border-radius: 8px;
  border: 1px solid var(--ds-border, rgb(234, 230, 222));
  box-shadow: 0 1px 2px rgba(25, 26, 28, .04);
  color: var(--text-primary, var(--ink)) !important; font-size: 12px !important; font-weight: 700 !important;
  line-height: 18px !important;
  cursor: pointer; white-space: nowrap; max-width: 260px; text-transform: none !important;
  letter-spacing: 0 !important; margin: 0 !important; vertical-align: middle;
  background: var(--bg-surface, #fff);
}
body:has(.fm-mark) label.fm-file::before { content: "⤒"; margin-right: 6px; font-weight: 400; }
body:has(.fm-mark) label.fm-file:hover { color: var(--text-primary, var(--ink)); }
body:has(.fm-mark) label.fm-file span { overflow: hidden; text-overflow: ellipsis; }
body:has(.fm-mark) label.fm-file input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}

/* Строка кнопок над списком: форма в <div>, ровный ряд с одинаковой высотой */
body:has(.fm-mark) .fm-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px;
}
body:has(.fm-mark) .fm-toolbar .inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
body:has(.fm-mark) .fm-toolbar :is(button, label.fm-file) { height: 36px !important; min-height: 36px !important; }

/* ---------- /money/summary ---------- */
body:has(.fm-summary) .fm-layers { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
body:has(.fm-summary) .fm-layers label.check { margin: 0; }
body:has(.fm-summary) .fm-sec-links { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
body:has(.fm-summary) .fm-sec-links .inline-form { display: inline-flex; margin: 0; }
/* Кнопки-ссылки («проверить правила сейчас», «разнести вручную», «снять привязку») —
   как соседние ссылки: цвет ссылки, без подчёркивания, без высоты кнопки */
:root body:has(.fm-summary) .pusk-generic-pane button.link-btn {
  min-height: 0 !important; height: auto !important; padding: 0 !important;
  border: 0 !important; background: none !important; box-shadow: none !important;
  font: inherit !important; font-weight: 400 !important;
  color: var(--accent-ink, var(--accent)) !important; text-decoration: none !important;
  cursor: pointer; display: inline !important;
}
:root body:has(.fm-summary) .pusk-generic-pane button.link-btn:hover { text-decoration: underline !important; }
:root body:has(.fm-summary) .pusk-generic-pane button.link-btn::before { display: none !important; }
body:has(.fm-summary) td .inline-form:has(> button.link-btn) { display: inline; margin-left: 10px; }

/* Чипы календаря выставления — плоские плашки, не кнопки */
:root body:has(.fm-summary) .pusk-generic-pane button.bill-chip {
  display: block !important; width: 100% !important;
  height: auto !important; min-height: 0 !important;
  margin-top: 2px !important; padding: 2px 5px !important;
  border: 0 !important; box-shadow: none !important; border-radius: 5px !important;
  font-size: 10.5px !important; font-weight: 600 !important; line-height: 1.35 !important;
  text-align: left !important; white-space: normal !important;
  background: var(--sand, #f1ede4) !important; color: var(--ink) !important;
}
:root body:has(.fm-summary) .pusk-generic-pane button.bill-chip.layer-акты { background: var(--accent-s) !important; }
:root body:has(.fm-summary) .pusk-generic-pane button.bill-chip.late { background: var(--alert-s) !important; color: var(--burgundy) !important; }
:root body:has(.fm-summary) .pusk-generic-pane button.bill-chip::before { display: none !important; }

/* ---------- /money ---------- */
body:has(.fm-money) .money-table th { white-space: nowrap; }
body:has(.fm-money) .money-table td.tools-cell {
  text-align: left !important; white-space: normal !important; width: auto !important;
  min-width: 180px; padding-top: 12px !important; padding-right: 40px !important;
  position: relative !important;
}
body:has(.fm-money) .money-table td.tools-cell .corner-tools {
  position: absolute !important; top: 50%; right: 6px; transform: translateY(-50%);
}
body:has(.fm-mark) .fm-nowrap { white-space: nowrap; }
body:has(.fm-money) .money-table .money-detail-row td { padding-top: 0 !important; padding-bottom: 10px !important; }

/* ---------- /acts ---------- */
body:has(.fm-acts) td.fm-actno { white-space: nowrap; }
body:has(.fm-acts) td.fm-actno .small { margin-left: 2px; }
body:has(.fm-acts) td.fm-todo { width: 420px; }
body:has(.fm-acts) td.fm-todo form.fm-sent {
  display: grid !important; grid-template-columns: 140px 1fr 136px; gap: 6px; align-items: end;
  margin: 0;
}
body:has(.fm-acts) td.fm-todo form.fm-close {
  display: grid !important; grid-template-columns: 1fr 136px; gap: 6px; align-items: end;
}
body:has(.fm-acts) td.fm-todo :is(form.fm-sent, form.fm-close) :is(input, select, button) {
  height: 36px !important; min-height: 36px !important;
}
body:has(.fm-acts) td.fm-todo input[type=date] { padding-left: 8px !important; padding-right: 6px !important; }
body:has(.fm-acts) td.fm-todo form.fm-sent > div { min-width: 0; margin: 0; }
body:has(.fm-acts) td.fm-todo :is(form.fm-sent, form.fm-close) :is(input, select) {
  width: 100% !important; min-width: 0 !important; box-sizing: border-box; margin: 0;
}
body:has(.fm-acts) td.fm-todo :is(form.fm-sent, form.fm-close) button { width: 100%; justify-content: center; margin: 0; }

/* ---------- /docs ---------- */
body:has(.fm-docs) .rail-form button { align-self: flex-start; width: auto !important; margin-top: 4px; }

/* ---------- Поле-галочка в строке фильтров: на линии с полями ---------- */
body:has(.fm-mark) form.inline:has(> .fm-checkf) { align-items: flex-end !important; }
body:has(.fm-mark) .fm-checkf { display: flex; align-items: center; min-height: 36px; margin: 0; }
body:has(.fm-mark) .fm-checkf label.check {
  display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important;
  font-size: 13px !important; font-weight: 400 !important; text-transform: none !important;
  letter-spacing: 0 !important; color: var(--text-primary, var(--ink)) !important; white-space: nowrap;
}

/* Строка формы: поля, кнопки и чипы — по нижнему краю */
body:has(.fm-mark) form.inline.fm-bottom { align-items: flex-end !important; }
body:has(.fm-mark) form.inline.fm-bottom > div > label:first-child { white-space: nowrap; }
body:has(.fm-mark) .pusk-generic-pane a.tag.fm-tagbtn {
  display: inline-flex !important; align-items: center; height: 36px; box-sizing: border-box;
  padding: 0 12px !important; margin: 0 !important; white-space: nowrap; align-self: flex-end;
}
body:has(.fm-mark) form.inline.fm-bottom > button { margin-bottom: 0 !important; align-self: flex-end; }
body:has(.fm-mark) form.inline.fm-bottom > .fm-hint-line { align-self: flex-end; line-height: 36px; }

/* Плитки-итоги (.tiles на /commissions, /reports/discrepancies): ровная сетка,
   число сверху, подпись под ним, суммы на одной линии */
body:has(.fm-mark) .tiles.fm-tiles {
  display: grid !important; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; align-items: stretch;
}
body:has(.fm-mark) .tiles.fm-tiles .tile {
  min-width: 0; display: flex; flex-direction: column; justify-content: flex-start;
}
body:has(.fm-mark) .tiles.fm-tiles .tile-value { margin: 0 0 4px; white-space: nowrap; }
body:has(.fm-comm) .tiles.fm-tiles { grid-template-columns: repeat(5, 1fr); }

/* ---------- /reports/pay-terms: одна карточка не растягивается ---------- */
body:has(.fm-payterms) .boxes.fm-boxes-one {
  display: grid !important; grid-template-columns: repeat(auto-fill, minmax(220px, 260px)) !important;
}

/* «нет данных» в карточке-итоге — не крупной цифрой, а тихой надписью на её месте */
:root body:has(.fm-mark) .pusk-generic-pane .box-num .fm-nodata {
  display: inline-block; font-size: 18px; font-weight: 600; line-height: 32px;
  color: var(--text-tertiary, var(--muted));
}

/* ---------- /economy/calendar: сетка месяца Пн…Вс ---------- */
body:has(.fm-ecal) table.fm-month { table-layout: fixed; width: 100%; }
body:has(.fm-ecal) table.fm-month th { text-align: left !important; width: 14.28%; }
body:has(.fm-ecal) table.fm-month td {
  vertical-align: top !important; text-align: left !important; height: 76px;
  padding: 8px 10px !important; position: relative; overflow-wrap: anywhere;
}
body:has(.fm-ecal) table.fm-month td.fm-pad { background: var(--bg-subtle, rgba(0,0,0,.015)) !important; }
body:has(.fm-ecal) table.fm-month td.fm-neg { background: var(--alert-s) !important; }
body:has(.fm-ecal) table.fm-month .fm-day { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
body:has(.fm-ecal) table.fm-month .fm-rest {
  margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--ds-border, var(--line));
  color: var(--text-secondary, var(--muted)); white-space: nowrap; font-size: 11.5px;
}
body:has(.fm-ecal) table.fm-month .fm-rest.red-text { color: var(--alert) !important; }
body:has(.fm-ecal) #economy-tasks td:last-child { width: 1%; text-align: center; }

/* ---------- /economy: 13 колонок в карточке ---------- */
body:has(.fm-econ) .fm-econ-wrap {
  overflow-x: auto !important; max-width: 100%;
  border: 1px solid var(--ds-border, var(--line)); border-radius: var(--ds-radius-lg, 12px);
  background: var(--bg-surface, var(--card)); box-shadow: var(--ds-shadow-xs, none);
}
body:has(.fm-econ) .pusk-generic-pane table.fm-econ-table {
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  width: 100%; margin: 0 !important; overflow: visible !important;
}
body:has(.fm-econ) table.fm-econ-table :is(th, td) { padding-left: 7px !important; padding-right: 7px !important; }
body:has(.fm-econ) table.fm-econ-table :is(th, td):first-child { padding-left: 14px !important; }
body:has(.fm-econ) table.fm-econ-table :is(th, td):last-child { padding-right: 14px !important; }
body:has(.fm-econ) table.fm-econ-table th { white-space: normal; font-size: 12px !important; vertical-align: bottom; }
body:has(.fm-econ) table.fm-econ-table td.right { white-space: nowrap; }
body:has(.fm-econ) table.fm-econ-table td.right div.muted { white-space: normal; min-width: 80px; }
body:has(.fm-econ) table.fm-econ-table td.fm-first,
body:has(.fm-econ) table.fm-econ-table th:first-child { min-width: 190px; }
body:has(.fm-econ) table.fm-econ-table .tfilter input { min-width: 0 !important; width: 100% !important; }

/* ---------- Широкая таблица: прокрутка внутри карточки, рамка видна целиком ---------- */
body:has(.fm-mark) .fm-scroll-card {
  overflow-x: auto !important; max-width: 100%;
  border: 1px solid var(--ds-border, var(--line)); border-radius: var(--ds-radius-lg, 12px);
  background: var(--bg-surface, var(--card)); box-shadow: var(--ds-shadow-xs, none);
}
body:has(.fm-mark) .pusk-generic-pane table.fm-scroll-table {
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  width: 100%; margin: 0 !important; overflow: visible !important;
}
body:has(.fm-mark) table.fm-scroll-table :is(th, td) { padding-left: 8px !important; padding-right: 8px !important; }
body:has(.fm-mark) table.fm-scroll-table :is(th, td):first-child { padding-left: 14px !important; }
body:has(.fm-mark) table.fm-scroll-table .tfilter input { min-width: 0 !important; width: 100% !important; }

/* ---------- /economy/costs ---------- */
body:has(.fm-ecosts) form.fm-costs-filter { flex-wrap: nowrap !important; gap: 8px !important; }
body:has(.fm-ecosts) form.fm-costs-filter > div { min-width: 0; flex: 0 1 auto; }
body:has(.fm-ecosts) form.fm-costs-filter > div :is(select, input) { width: 100% !important; min-width: 0 !important; }
body:has(.fm-ecosts) form.fm-costs-filter > div:nth-of-type(1) { flex-basis: 96px; }
body:has(.fm-ecosts) form.fm-costs-filter > div:nth-of-type(2) { flex-basis: 128px; }
body:has(.fm-ecosts) form.fm-costs-filter > div:nth-of-type(3) { flex-basis: 150px; }
body:has(.fm-ecosts) form.fm-costs-filter > div:nth-of-type(4) { flex-basis: 210px; }
body:has(.fm-ecosts) form.fm-costs-filter > div:nth-of-type(5) { flex-basis: 190px; }
body:has(.fm-ecosts) form.fm-costs-filter > div.fm-grow { flex: 1 1 180px; }
body:has(.fm-ecosts) form.fm-costs-filter > button { flex: 0 0 auto; }
body:has(.fm-ecosts) :is(form.fm-costs-filter, form.fm-cost-add) .pick-box { display: block; width: 100%; }
body:has(.fm-ecosts) :is(form.fm-costs-filter, form.fm-cost-add) .pick-box .pick-input { width: 100% !important; min-width: 0 !important; box-sizing: border-box; }
body:has(.fm-ecosts) form.fm-cost-add { flex-wrap: wrap !important; gap: 10px 8px !important; }
body:has(.fm-ecosts) form.fm-cost-add > div { margin: 0; }
body:has(.fm-ecosts) form.fm-cost-add > div :is(select, input:not([type=checkbox])) { width: 100% !important; min-width: 0 !important; }
body:has(.fm-ecosts) form.fm-cost-add > div:nth-of-type(1),
body:has(.fm-ecosts) form.fm-cost-add > div:nth-of-type(2) { flex: 0 0 150px; }
body:has(.fm-ecosts) form.fm-cost-add > div:nth-of-type(3) { flex: 0 0 290px; }
body:has(.fm-ecosts) form.fm-cost-add > div:nth-of-type(4) { flex: 0 0 150px; }
body:has(.fm-ecosts) form.fm-cost-add > div.fm-who { flex: 1 1 200px; }
body:has(.fm-ecosts) form.fm-cost-add > div.fm-purpose { flex: 1 1 360px; min-width: 0 !important; }
body:has(.fm-ecosts) form.fm-cost-add > div.fm-sum { flex: 0 0 150px; }

/* ---------- /projects ---------- */
body:has(.fm-projects) td.fm-comm-cell { white-space: nowrap; }
body:has(.fm-projects) td.fm-comm-cell .inline-form { display: inline-flex; margin: 0; }
body:has(.fm-projects) td.fm-comm-cell label.paid-mark {
  display: inline-flex !important; align-items: center; gap: 6px; white-space: nowrap;
  margin: 0 !important; font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important;
}
body:has(.fm-projects) td.fm-comm-cell label.paid-mark input { position: static !important; margin: 0 !important; flex: 0 0 auto; }

/* ---------- /time ---------- */
body:has(.fm-time) .pusk-generic-pane .panel > h3:first-child { margin-top: 0 !important; }
body:has(.fm-time) .pusk-generic-pane .panel form.inline { align-items: flex-end; }
body:has(.fm-time) td.fm-edit form.inline {
  display: flex !important; flex-wrap: nowrap !important; align-items: center !important; gap: 8px; margin: 0;
}
body:has(.fm-time) td.fm-edit input[name=duration] { width: 80px !important; min-width: 0 !important; }
body:has(.fm-time) td.fm-edit label.check {
  display: inline-flex !important; align-items: center; gap: 4px; margin: 0 !important;
  font-size: 12px !important; font-weight: 400 !important; text-transform: none !important;
  letter-spacing: 0 !important; white-space: nowrap;
}
body:has(.fm-time) td.fm-edit button { margin: 0 !important; }
