/* ==========================================================================
   Раздел «Ежедневные продажи»: отчёты 1С о розничных продажах.
   Основа — /style.css портала (таблицы, кнопки, выпадающий выбор). Здесь
   только своё: строка фильтров, итоги как внизу документа 1С, метки смены.
   Раздел плотный, как «Товар и остатки» (.content.dense).
   ========================================================================== */

.ds-page { container-type: inline-size; }

.ds-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ds-filters .spacer { flex: 1; }
.ds-range { display: inline-flex; align-items: center; gap: 6px; }
.ds-dash { color: var(--text-3); }
.ds-date {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--separator-strong);
}
.ds-date .icon { width: 16px; height: 16px; color: var(--text-2); }
.ds-date input {
  border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--text); font-variant-numeric: tabular-nums; padding: 0; min-height: 40px;
}
.ds-date input:focus { outline: none; }
.ds-date:focus-within { border-color: var(--accent); }
.ds-quick { display: inline-flex; gap: 4px; }
.ds-pick { display: inline-flex; align-items: center; gap: 6px; }
/* Цели нажатия не меньше 44px — и у маленьких кнопок раздела */
.ds-filters .btn, .ds-filters .drop-btn { min-height: 44px; }
.ds-last { font-size: 13px; color: var(--text-3); margin-bottom: 18px; }

.ds-table td.num, .ds-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ds-table td { padding: 10px 14px; }
.ds-table th { padding: 10px 14px; }
.ds-table .neg { color: var(--red); }
.ds-table tfoot td { font-weight: 800; background: var(--surface-2); border-top: 1px solid var(--separator); border-bottom: 0; }
.ds-table td.muted { font-size: 13px; }
.ds-click { cursor: pointer; }
.ds-click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ds-lines td.c-name { min-width: 280px; }
/* Сводка строки товара нужна только карточке; в таблице те же цифры стоят по колонкам */
.ds-lines td.c-meta { display: none; }
.ds-days { margin-bottom: 16px; }

.ds-totals {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-top: 16px;
}
.ds-total {
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--separator); border-radius: var(--r-md);
}
.ds-total span { display: block; font-size: 12.5px; color: var(--text-3); }
.ds-total b { display: block; margin-top: 4px; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ds-total.neg b { color: var(--red); }
.ds-total.grand { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.ds-total.grand b { color: var(--accent-ink); }

.ds-pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--pill);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-inset); color: var(--text-2);
}
.ds-pill.ok { background: var(--green-soft); color: var(--green); }
.ds-pill.warn { background: var(--amber-soft); color: var(--amber); }
.ds-pill.bad { background: var(--red-soft); color: var(--red); }

.ds-banner {
  padding: 14px 16px; margin-bottom: 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--separator); font-size: 14.5px; color: var(--text-2);
}
.ds-banner.warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.ds-docs { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 13.5px; color: var(--text-2); }
.ds-docs .icon { width: 16px; height: 16px; color: var(--green); }
.ds-note { margin: 12px 0; font-size: 13.5px; color: var(--text-3); }
.ds-note.bad { color: var(--red); }
.ds-check {
  margin-bottom: 16px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--separator); font-size: 14px;
}
.ds-check-row + .ds-check-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--separator); }
.ds-check ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); }

/* ==========================================================================
   Под ширину раздела, а не экрана: ноутбук 1024 с боковым меню и планшет
   без него оставляют разделу одинаково мало места. Шаги:
   ≤ 980 — магазины карточками, итоги в 4 колонки;
   ≤ 860 — товары списком «название · сумма / подробности»;
   ≤ 640 — телефон: итоги наверху, фильтры столбиком, в днях только итог.
   ========================================================================== */

@container (max-width: 980px) {
  .ds-totals { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .ds-cards-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .ds-cards-wrap .table-scroll { overflow: visible; }
  .ds-stores { display: flex; flex-direction: column; min-width: 0; }
  .ds-stores thead { display: none; }
  .ds-stores tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  /* «Итого» — первым: на узком экране это главная цифра */
  .ds-stores tfoot { display: block; order: -1; margin-bottom: 12px; }
  .ds-stores tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px;
    padding: 14px 16px; background: var(--surface);
    border: 1px solid var(--separator); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  }
  .ds-stores tfoot tr { background: var(--accent-soft); border-color: var(--accent-soft-2); box-shadow: none; }
  .ds-stores td, .ds-stores tfoot td {
    padding: 0; border: 0; background: none; text-align: left; font-weight: 600; order: 3; min-width: 0;
  }
  /* td.num в таблице выровнен вправо; в карточке значение стоит под подписью */
  .ds-stores td.num { text-align: left; }
  .ds-stores td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font-size: 12px; font-weight: 600; color: var(--text-3);
  }
  .ds-stores td.c-name { grid-column: 1 / 3; order: 0; font-size: 16px; }
  .ds-stores td.c-state { grid-column: 3; order: 1; justify-self: end; text-align: right; }
  .ds-stores td.c-state:empty { display: none; }
  .ds-stores td.c-total { grid-column: 1 / -1; order: 2; padding-bottom: 8px; border-bottom: 1px solid var(--separator); }
  .ds-stores tfoot td.c-total { border-bottom-color: var(--accent-soft-2); }
  .ds-stores td.c-total b { font-size: 24px; font-weight: 800; }
  .ds-stores tfoot td.c-total b { color: var(--accent-ink); }
}

/* Планшет и узкий ноутбук: в «Итого» места хватает на шесть показателей в ряд */
@container (min-width: 641px) and (max-width: 980px) {
  .ds-stores tfoot tr { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ds-stores tfoot td.c-name, .ds-stores tfoot td.c-total { grid-column: 1 / -1; }
}

@container (max-width: 860px) {
  .ds-lines { display: block; min-width: 0; }
  .ds-lines thead { display: none; }
  .ds-lines tbody { display: block; }
  .ds-lines tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px;
    padding: 12px 16px; border-bottom: 1px solid var(--separator);
  }
  .ds-lines tbody tr:last-child { border-bottom: 0; }
  .ds-lines td { padding: 0; border: 0; }
  .ds-lines td.c-n, .ds-lines td.c-col { display: none; }
  .ds-lines td.c-name { min-width: 0; font-weight: 600; line-height: 1.35; }
  .ds-lines td.c-sum { grid-column: 2; grid-row: 1; font-weight: 800; }
  .ds-lines td.c-meta { display: block; grid-column: 1 / -1; font-size: 13px; color: var(--text-3); }
  .ds-ret { color: var(--red); font-weight: 600; }
}

@container (max-width: 640px) {
  .ds-filters { gap: 8px; }
  .ds-range { width: 100%; }
  .ds-date { flex: 1; min-width: 0; }
  .ds-date input { width: 100%; min-width: 0; }
  .ds-quick { width: 100%; }
  .ds-quick .btn { flex: 1; justify-content: center; }
  .ds-pick { width: 100%; }
  .ds-pick .drop { flex: 1; min-width: 0; }
  .ds-pick .drop-btn { width: 100%; }
  .ds-pick .drop-btn > span { flex: 1; text-align: left; }
  /* Проверка 1С — значком: подпись не помещается рядом с выбором магазина */
  #ds-check { width: 44px; padding: 0; justify-content: center; flex: none; }
  #ds-check .btn-label { display: none; }
  .ds-filters .spacer { display: none; }
  #ds-pull { width: 100%; justify-content: center; }

  .ds-stores tbody { grid-template-columns: minmax(0, 1fr); }

  .ds-body { display: flex; flex-direction: column; }
  .ds-body .ds-totals { order: -1; margin: 0 0 16px; }
  .ds-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ds-total.grand { grid-column: 1 / -1; order: -1; }
  .ds-total.grand b { font-size: 24px; }
  .ds-total b { font-size: 16px; }

  .ds-days-table { min-width: 0; }
  .ds-days-table .c-more { display: none; }
  .ds-days-table td, .ds-days-table th { padding: 10px 12px; }
}
