/* Калькулятор шире колонки текста.

   Статья ограничена инлайновым max-width:800px — для помесячного графика на
   360 точек этого мало. Раздвигаем саму карточку статьи до ширины контейнера
   темы (--container, 1140px): дальше нельзя, там начинаются рекламные
   колонки, они position: fixed и считаются от этой же переменной.

   Именно карточку, а не виджет: отрицательные поля вытащили бы калькулятор
   за белую подложку, и он повис бы на сером фоне.

   :has() поддерживают все актуальные браузеры; там, где нет, страница просто
   останется прежней ширины — некрасиво, но не сломано. */
.bf-post:has(.bpf-calc-mount) {
  max-width: var(--container, 1140px) !important;
  /* У статьи инлайновый padding: 20px 0 — боковых отступов нет вовсе, и
     текст с полями прилипает к краю белой карточки. Задаём явно; правило
     действует только на страницах с калькулятором. */
  padding: 28px 34px !important;
}

@media (max-width: 640px) {
  .bf-post:has(.bpf-calc-mount) {
    padding: 18px 16px !important;
  }
}

/* Калькуляторы «Без пафоса — финансы».
   Переменные берутся из темы сайта; запасные значения нужны, чтобы блок не
   разъехался, если калькулятор вставят на страницу без темы. */

.bfc {
  /* Запас на случай, если калькулятор вставили в контейнер без отступов.
     На своих страницах отступ даёт карточка статьи, поэтому здесь ноль. */
  padding: 0;

  --bfc-accent: var(--accent, #ff6b35);
  --bfc-ink: var(--text, #1c1a1a);
  --bfc-muted: var(--text-muted, #8a8480);
  --bfc-border: var(--border, #e6e2de);
  --bfc-card: var(--white, #fff);
  --bfc-radius: var(--radius, 12px);
  --bfc-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.06));

  color: var(--bfc-ink);
  font-size: 16px;
  line-height: 1.5;
  max-width: 100%;
}

.bfc *,
.bfc *::before,
.bfc *::after {
  box-sizing: border-box;
}

.bfc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.bfc-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.bfc-foot {
  align-items: center;
  border-top: 1px solid var(--bfc-border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
}
.bfc-foot .bfc-disclaimer {
  flex: 1 1 340px;
  margin: 0;
}

.bfc-share {
  background: transparent;
  flex: 0 0 auto;
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  color: var(--bfc-ink);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  transition: border-color 0.15s, color 0.15s;
}
.bfc-share:hover {
  border-color: var(--bfc-accent);
  color: var(--bfc-accent);
}
.bfc-share--done {
  border-color: var(--bfc-accent);
  color: var(--bfc-accent);
}

.bfc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Фирменные цвета мессенджеров: кнопку ищут глазами по цвету, а не по тексту. */
.bfc-share--tg {
  border-color: #2aabee;
  color: #1d8ecf;
}
.bfc-share--tg:hover {
  background: #2aabee;
  border-color: #2aabee;
  color: #fff;
}
.bfc-share--vk {
  border-color: #0077ff;
  color: #0077ff;
}
.bfc-share--vk:hover {
  background: #0077ff;
  border-color: #0077ff;
  color: #fff;
}

.bfc-share--sm {
  font-size: 0.78rem;
  padding: 6px 11px;
}

/* Ввод ------------------------------------------------------------------ */

/* Колонок ровно четыре, а не auto-fit: на широкой карточке подбор давал
   пять узких колонок и одинокое поле в следующем ряду. */
.bfc-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 14px;
}

.bfc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.bfc-field-label {
  color: var(--bfc-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bfc-input-wrap {
  align-items: center;
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  display: flex;
  gap: 6px;
  padding: 0 12px;
  transition: border-color 0.15s;
}
.bfc-input-wrap:focus-within {
  border-color: var(--bfc-accent);
}

.bfc-input-wrap input,
.bfc-input-wrap select {
  background: transparent;
  border: 0;
  color: inherit;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
  outline: none;
  padding: 10px 0;
  width: 100%;
}

.bfc-suffix {
  color: var(--bfc-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.bfc-hint {
  color: var(--bfc-muted);
  font-size: 0.72rem;
}

.bfc-toggle {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
  margin-bottom: 10px;
}
.bfc-toggle input {
  accent-color: var(--bfc-accent);
  height: 17px;
  width: 17px;
}

/* Списки долгов и обязательств ------------------------------------------ */

.bfc-list {
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  margin-bottom: 14px;
  padding: 12px 14px;
}

.bfc-list-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.bfc-list-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

/* Строка списка: название тянется, числовые поля фиксированы, крестик с краю. */
.bfc-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto;
  margin-bottom: 8px;
}

.bfc-row:last-child {
  margin-bottom: 0;
}

[data-oblig-row] {
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)) auto;
}

/* Товар в корзине шринкфляции: название, единицы и четыре числа — «было» и
   «стало» в весе и в рублях. Числовые колонки уже прочих: в них помещается
   «180» и «1 200», а место нужно названию. */
[data-item-row] {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) repeat(4, minmax(0, 0.8fr)) auto;
}

.bfc-field--name .bfc-input-wrap input {
  font-weight: 500;
}

/* Название товара — на половину ряда: «Растительное масло» в четверть
   колонки не помещается. */
.bfc-field--wide {
  grid-column: span 2;
}

.bfc-remove {
  background: transparent;
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  color: var(--bfc-muted);
  cursor: pointer;
  font-size: 1.2rem;
  height: 42px;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
  width: 42px;
}
.bfc-remove:hover {
  border-color: #c1440e;
  color: #c1440e;
}

/* Опросник индекса здоровья ---------------------------------------------- */

.bfc-quiz-q {
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  margin: 0 0 12px;
  padding: 12px 16px;
}
.bfc-quiz-title {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0 4px;
}
.bfc-quiz-option {
  align-items: baseline;
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  gap: 9px;
  padding: 5px 2px;
}
.bfc-quiz-option input {
  accent-color: var(--bfc-accent);
  flex: 0 0 auto;
}

/* Шкала зон индекса */
.bfc-scale {
  margin: 6px 0 14px;
  position: relative;
}
.bfc-scale-track {
  border-radius: 999px;
  display: flex;
  height: 12px;
  overflow: hidden;
}
.bfc-zone--0 { background: #d64541; }
.bfc-zone--1 { background: #e98b39; }
.bfc-zone--2 { background: #e3c14c; }
.bfc-zone--3 { background: #7fbf6a; }
.bfc-zone--4 { background: #2e9e5b; }
.bfc-scale-marker {
  background: var(--bfc-ink);
  border: 2px solid var(--bfc-card);
  border-radius: 999px;
  height: 20px;
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  width: 20px;
}

/* Слайдер стресс-теста */
.bfc-input-wrap--bare {
  background: transparent;
  border: 0;
  padding: 0;
}
.bfc-field--slider input[type="range"] {
  accent-color: var(--bfc-accent);
  padding: 14px 0;
  width: 100%;
}

/* Итоговые строки таблиц и чек-листы */
.bfc-total-row td {
  border-top: 2px solid var(--bfc-border);
  font-weight: 700;
}
.bfc-checklist {
  font-size: 0.88rem;
  margin: 8px 0 4px;
  padding-left: 20px;
}
.bfc-checklist li {
  margin: 4px 0;
}

/* Предупреждения ---------------------------------------------------------- */

.bfc-alarm {
  background: rgba(193, 68, 14, 0.06);
  border: 1px solid rgba(193, 68, 14, 0.35);
  border-radius: var(--bfc-radius);
  margin: 16px 0;
  padding: 16px 18px;
}
.bfc-alarm h4 {
  color: #c1440e;
  font-size: 1.05rem;
  margin: 0 0 8px;
}
.bfc-alarm p,
.bfc-alarm li {
  font-size: 0.9rem;
  margin: 6px 0;
}
.bfc-alarm ul {
  margin: 6px 0;
  padding-left: 20px;
}

.bfc-compare {
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  margin-bottom: 14px;
  padding: 14px 16px;
}
.bfc-compare h4 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}
.bfc-compare p {
  font-size: 0.9rem;
  margin: 0;
}

/* Результат ------------------------------------------------------------- */

.bfc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.bfc-stat {
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  box-shadow: var(--bfc-shadow);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
}

.bfc-stat-label {
  color: var(--bfc-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bfc-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
}

.bfc-stat-note {
  color: var(--bfc-muted);
  font-size: 0.72rem;
}

.bfc-stat--accent {
  border-color: var(--bfc-accent);
}
.bfc-stat--accent .bfc-stat-value {
  color: var(--bfc-accent);
}
.bfc-stat--warn .bfc-stat-value {
  color: #c1440e;
}
.bfc-stat--muted .bfc-stat-value {
  color: var(--bfc-muted);
  font-size: 1.1rem;
}

/* Графики --------------------------------------------------------------- */

.bfc-chart {
  background: var(--bfc-card);
  overflow: hidden;
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  margin-bottom: 14px;
  padding: 12px;
}

/* Пропорции держит сам viewBox: высота считается от ширины, поэтому
   подписи не расплющиваются на широких экранах. */
.bfc-chart svg {
  display: block;
  height: auto;
  width: 100%;
}

.bfc-axis {
  fill: var(--bfc-muted);
  font-size: 17px;
}

.bfc-grid {
  stroke: var(--bfc-border);
  stroke-width: 1;
}

.bfc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.bfc-legend-item {
  align-items: center;
  color: var(--bfc-muted);
  display: flex;
  font-size: 0.78rem;
  gap: 6px;
}
.bfc-legend-item i {
  border-radius: 3px;
  display: inline-block;
  height: 11px;
  width: 11px;
}

/* Таблицы и раскрывашки -------------------------------------------------- */

.bfc-details {
  border: 1px solid var(--bfc-border);
  border-radius: var(--bfc-radius);
  margin-bottom: 12px;
  padding: 10px 14px;
}
.bfc-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  list-style: none;
}
.bfc-details > summary::-webkit-details-marker {
  display: none;
}
.bfc-details > summary::before {
  content: "▸ ";
  color: var(--bfc-accent);
}
.bfc-details[open] > summary::before {
  content: "▾ ";
}
.bfc-block {
  margin-bottom: 14px;
}

/* Длинная таблица прокручивается внутри себя: страница по горизонтали
   ехать не должна ни на каком экране. */
.bfc-table-wrap {
  margin-top: 10px;
  max-height: 420px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.bfc-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 520px;
  width: 100%;
}
.bfc-table th,
.bfc-table td {
  border-bottom: 1px solid var(--bfc-border);
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
}
.bfc-table th {
  background: var(--bfc-card);
  color: var(--bfc-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}
.bfc-table th:first-child,
.bfc-table td:first-child {
  text-align: left;
}
.bfc-negative {
  color: #c1440e;
}
.bfc-muted {
  color: var(--bfc-muted);
}

.bfc-note,
.bfc-disclaimer {
  color: var(--bfc-muted);
  font-size: 0.78rem;
  margin: 10px 0 0;
}

.bfc-error {
  background: rgba(193, 68, 14, 0.08);
  border-radius: var(--bfc-radius);
  color: #c1440e;
  font-size: 0.88rem;
  margin: 12px 0;
  padding: 10px 14px;
}

@media (max-width: 960px) {
  .bfc-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* На узком экране строка списка перестраивается в два ряда: пять полей
   в одну линию читаются только на десктопе. */
@media (max-width: 820px) {
  .bfc-row,
  [data-oblig-row],
  [data-item-row] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }
  .bfc-field--name {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  /* На телефоне кнопки в ряд не помещаются — растягиваем на всю ширину. */
  .bfc-actions {
    width: 100%;
  }
  .bfc-actions .bfc-share {
    flex: 1 1 auto;
  }
  .bfc-form {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .bfc-stats {
    grid-template-columns: 1fr 1fr;
  }
  .bfc-stat-value {
    font-size: 1.1rem;
  }
  .bfc-chart {
    padding: 8px;
  }
  .bfc-axis {
    font-size: 21px;
  }
}

@media (max-width: 400px) {
  .bfc-form {
    grid-template-columns: 1fr;
  }
  /* В одну колонку растягивать нечего, а span 2 добавил бы вторую. */
  .bfc-field--wide {
    grid-column: auto;
  }
}
