/* ===== Таблицы в статьях: десктоп — таблица, мобилка — карточки =====
   Работает в паре со скриптом tables.js (он ставит data-label ячейкам
   и атрибут data-cards таблице). Стили касаются только таблиц без class. */

table:not([class]) {
  --tbl-border: #e3e8ee;
  --tbl-head-bg: #f2f6fa;
  --tbl-zebra: #fafbfc;
  --tbl-text: #2b2f33;

  width: 100%;
  margin: 24px 0 28px;
  border-collapse: collapse;
  border: 1px solid var(--tbl-border);
  font-size: 15px;
  line-height: 1.45;
  color: var(--tbl-text);
  background: #fff;
}
table:not([class]) th,
table:not([class]) td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--tbl-border);
  font-weight: 400;
}
/* шапка — только первая строка таблицы */
table:not([class]) tr[data-head] > *,
table:not([class]):not([data-cards]) thead tr:first-child th {
  background: var(--tbl-head-bg);
  font-weight: 600;
}
/* первый столбец — подпись строки */
table:not([class]) tr:not([data-head]) > *:first-child { font-weight: 600; }
table:not([class]):not([data-cards]) thead tr:first-child > * { font-weight: 600; }
table:not([class]) tbody tr:nth-child(even) > * { background: var(--tbl-zebra); }
table:not([class]) td strong,
table:not([class]) th strong { font-weight: inherit; }
table:not([class]) p { margin: 0; }

/* ===== Мобильная версия: каждая строка — карточка ===== */
@media (max-width: 768px) {
  table[data-cards]:not([class]),
  table[data-cards]:not([class]) thead,
  table[data-cards]:not([class]) tbody,
  table[data-cards]:not([class]) tr,
  table[data-cards]:not([class]) th,
  table[data-cards]:not([class]) td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  table[data-cards]:not([class]) {
    border: 0;
    background: transparent;
    margin: 20px 0 24px;
    font-size: 15px;
  }
  /* строка с заголовками колонок скрыта — заголовки идут подписями в ячейках */
  table[data-cards]:not([class]) tr[data-head] { display: none !important; }

  table[data-cards]:not([class]) tr {
    margin: 0 0 16px;
    border: 1px solid var(--tbl-border);
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
  }
  table[data-cards]:not([class]) tr:last-child { margin-bottom: 0; }
  table[data-cards]:not([class]) tr > th,
  table[data-cards]:not([class]) tr > td {
    border: 0;
    border-bottom: 1px solid var(--tbl-border);
    padding: 12px 14px;
    background: #fff !important;
    font-weight: 400 !important;
  }
  table[data-cards]:not([class]) tr > *:last-child { border-bottom: 0; }

  /* подпись = название колонки */
  table[data-cards]:not([class]) [data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-weight: 700;
    color: #2b2f33;
  }
}
