/* Поверх vanilla.css — только бренд-токены и то, чего в библиотеке нет:
   плотная таблица на сотни строк, липкая шапка и печать. Сам vanilla.css
   не редактируем, чтобы его можно было обновить целиком. */

:root {
  --color-primary: #1f6feb;
  --color-on-primary: #fff;
  --color-secondary: #f1f5f9;

  --row-hover: #f8fafc;
  --sticky-bg: #fff;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

body {
  padding: 1rem 1.25rem 3rem;
  gap: 1.25rem;
}

/* ---------- шапка приложения ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-divider);
}

.app-header .site-name {
  font-size: 1.125rem;
  font-weight: 800;
}

.app-header .nav {
  flex: 1;
}

.app-header .nav a.active {
  font-weight: bold;
  color: var(--color-primary);
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- плотная таблица ---------- */

.table.dense {
  font-size: 0.8125rem;
}

.table.dense th,
.table.dense td {
  padding: 0.3125rem 0.5rem;
  vertical-align: top;
}

/* .table-wrapper из vanilla объявляет overflow-x: auto, а это делает его
   контейнером прокрутки по обеим осям. Поэтому sticky-шапка привязывается
   к нему, а не к окну, и работает, только если контейнер сам прокручивается
   по вертикали — задаём ему высоту. Заодно горизонтальная прокрутка широкой
   таблицы остаётся внутри, и страница не едет вбок. */
.table-wrapper.scroll-y {
  max-height: calc(100vh - 13rem);
  overflow: auto;
}

.table.sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sticky-bg);
  box-shadow: inset 0 -1px 0 var(--color-border);
}

.table tbody tr:hover {
  background: var(--row-hover);
}

.table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table .nowrap {
  white-space: nowrap;
}

/* Наименования доходят до 300+ символов у импортных позиций:
   держим их в две строки, полный текст — в карточке. */
.table .cell-product {
  min-width: 18rem;
  max-width: 34rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table th.sortable:hover {
  color: var(--color-primary);
}

.sort-arrow {
  color: var(--color-primary);
}

.table tbody tr.clickable {
  cursor: pointer;
}

/* ---------- мелочи ---------- */

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters .input,
.filters .select {
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
}

.filters .search-bar {
  flex: 1;
  min-width: 14rem;
}

.totals-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 0.875rem;
}

.totals-bar b {
  font-variant-numeric: tabular-nums;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.badge.muted {
  background: var(--color-secondary);
  color: var(--color-muted);
}

.login-wrap {
  max-width: 22rem;
  margin: 4rem auto;
}

.toast-root {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.toast {
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  background: #111;
  color: #fff;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
  max-width: 24rem;
}

.toast.danger {
  background: var(--color-danger);
}

.modal.wide {
  max-width: 52rem;
}

.spinner {
  padding: 2rem;
  text-align: center;
  color: var(--color-muted);
}

/* ---------- печать ---------- */

@media print {
  .app-header,
  .filters,
  .pagination,
  .no-print {
    display: none !important;
  }

  body {
    padding: 0;
  }

  .table-wrapper {
    border: none;
    overflow: visible;
  }

  .table.dense {
    font-size: 0.6875rem;
  }
}
