:root {
  color-scheme: light;
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d7e0ec;
  --text: #0b1220;
  --muted: #5b6475;
  --primary: #1d4f91;
  --primary-dark: #153b6f;
  --secondary: #344256;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --success: #15803d;
  --warning: #9a5b00;
  --danger: #b42318;
  --focus: #f59e0b;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top right, rgba(29, 79, 145, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 10px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 16px rgba(15, 23, 42, 0.06);
}

.brand {
  display: grid;
  gap: 1px;
  flex: 0 0 auto;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--secondary);
  font-weight: 600;
}

.nav a:hover {
  background: var(--surface-soft);
  color: var(--primary);
  text-decoration: none;
}

.nav a.active {
  background: #e7eef8;
  color: var(--primary-dark);
}

.nav-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.nav-toggle:hover {
  background: #e8edf5;
  border-color: #c5d0e0;
}

.nav-toggle-box {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  transition: transform 0.22s ease;
}

.nav-toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 1px;
  background: var(--text);
  transition: transform 0.22s ease, opacity 0.18s ease;
}

.topbar--nav-open .nav-toggle-box {
  height: 0;
  justify-content: center;
}

.topbar--nav-open .nav-toggle-bar:nth-child(1) {
  position: absolute;
  top: 0;
  transform: rotate(45deg);
}

.topbar--nav-open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.topbar--nav-open .nav-toggle-bar:nth-child(3) {
  position: absolute;
  top: 0;
  transform: rotate(-45deg);
}

.topbar-panel {
  display: contents;
}

.topbar-user {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: grid;
  gap: 1px;
  min-width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.user-chip strong {
  font-size: 14px;
}

.user-chip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.logout-form {
  margin: 0;
}

.topbar-user .btn {
  min-height: 38px;
  padding: 7px 12px;
}

@media (max-width: 899px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 58px);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .topbar-panel {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    width: 100%;
    gap: 14px;
    padding: 12px 0 4px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }

  .topbar--nav-open .topbar-panel {
    display: flex;
  }

  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
  }

  .nav a {
    width: 100%;
    justify-content: flex-start;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 8px;
  }

  .topbar-user {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .user-chip {
    min-width: 0;
  }

  .logout-form .btn {
    width: 100%;
  }
}

.page {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.page-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 22px;
}

.muted {
  color: var(--muted);
}

.actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.table-actions-counterparty {
  justify-content: flex-end;
  gap: 6px;
}

.table-actions-counterparty .btn {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.table-actions-counterparty form {
  margin: 0;
}

.table-actions-counterparty form .btn {
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-light {
  background: #eef2f7;
  color: var(--text);
  border-color: #d4dbe6;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #14857b);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--accent-dark), #0f766e);
}

.panel,
.form-panel {
  margin-bottom: 22px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-head-copy {
  display: grid;
  gap: 6px;
  max-width: 720px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-head-compact {
  margin-bottom: 12px;
}

.page-head-compact .page-head-copy p {
  display: none;
}

.filters-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.filters-toolbar .filter-search {
  flex: 1 1 11rem;
  min-width: 11rem;
  max-width: 15rem;
  margin: 0;
}

.filters-toolbar-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.filters-toolbar-count {
  grid-area: count;
  margin: 0;
  font-size: 13px;
}

.filters-toolbar-count strong {
  font-size: 14px;
}

/* Единый вид всех контролов в панели фильтров */
.filters-toolbar .form-control,
.filters-toolbar .form-select,
.filters-toolbar .combo-trigger {
  box-sizing: border-box;
  width: 100%;
  min-height: 36px;
  height: 36px;
  padding: 6px 10px;
  border: 1px solid #b9c4d4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}

.filters-toolbar .form-select {
  width: auto;
  min-width: 7.5rem;
  max-width: 9.5rem;
  padding-right: 28px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filters-toolbar .combo-trigger {
  padding-right: 28px;
  font-weight: 500;
  text-align: left;
}

.filters-toolbar .combo-trigger::after {
  right: 10px;
  font-size: 12px;
}

.filters-toolbar .combo-label {
  font-size: 14px;
  font-weight: 500;
}

.filters-toolbar .combo-label.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.filters-toolbar .btn-sm {
  min-height: 36px;
  height: 36px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
}

.btn-sm {
  min-height: 40px;
  padding: 7px 14px;
  font-size: 15px;
}

.filter-compact {
  display: block;
  min-width: 0;
}

.filters-toolbar label.filter-compact,
.filters-toolbar label.filter-check {
  display: block;
  gap: 0;
  margin: 0;
  font-weight: inherit;
}

.multi-select-field--compact {
  min-width: 7.5rem;
  max-width: 9.5rem;
}

.filters-toolbar .multi-select-field--compact {
  flex: 0 1 9rem;
}

.filters-toolbar .multi-combo-control .combo-menu {
  left: 0;
  right: auto;
  width: max(100%, 15.5rem);
  min-width: 15.5rem;
}

.filters-toolbar .combo-option {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}

.filters-toolbar .combo-empty {
  font-size: 14px;
  font-weight: 500;
}

.filters-toolbar .filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-height: 36px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
  cursor: pointer;
}

.filters-toolbar .filter-check .form-check-input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.filter-price-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.report-date-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filters-toolbar .filter-price .form-control {
  width: 10rem;
  min-width: 10rem;
  max-width: 10rem;
  padding-left: 10px;
  padding-right: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.filters-toolbar .filter-date .form-control {
  width: 9.5rem;
  min-width: 9.5rem;
  max-width: 9.5rem;
  padding-left: 10px;
  padding-right: 10px;
}

.filter-price-sep {
  color: var(--muted);
  font-weight: 700;
  user-select: none;
}

.catalog-table-details {
  margin-top: 8px;
}

.catalog-table-details > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  padding: 4px 2px 12px;
  list-style: none;
}

.catalog-table-details > summary::-webkit-details-marker {
  display: none;
}

.catalog-table-details > summary::before {
  content: "▸ ";
}

.catalog-table-details[open] > summary::before {
  content: "▾ ";
}

.filters-panel {
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.filters-panel-head h2 {
  font-size: 20px;
}

.filters-grid-catalog {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.filter-field-wide,
.multi-select-field {
  grid-column: span 2;
  min-width: 0;
}

.filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.filters-actions .btn {
  min-width: 132px;
}

select.native-multi-select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.label-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
  white-space: nowrap;
  color: var(--secondary);
  font-weight: 700;
  line-height: 1.2;
}

.required-mark {
  display: inline-block;
  margin-left: 2px;
  color: var(--danger);
  font-weight: 800;
  line-height: 1;
  flex: 0 0 auto;
}

.form-field-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-field-cell .field-help {
  font-weight: 600;
}

.form-grid-3col {
  align-items: end;
}

.form-grid-3col .form-field-cell .combo-trigger,
.form-grid-3col .form-field-cell .form-control,
.form-grid-3col .form-field-cell .tag-input-shell .form-control {
  width: 100%;
}

.form-grid-hint {
  grid-column: 1 / -1;
  margin: -4px 0 0;
}

.multi-select-field .combo-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-combo-control .combo-menu {
  max-height: 280px;
}

.multi-combo-control .combo-options {
  max-height: 280px;
}

.catalog-summary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .filters-toolbar-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filters-toolbar .filter-search {
    grid-column: 1 / -1;
    max-width: none;
    width: 100%;
  }

  .filters-toolbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
  }

  .filters-toolbar-actions .btn {
    flex: 1;
  }

  .multi-select-field--compact,
  .filter-compact .form-select {
    max-width: none;
    width: 100%;
  }

  .filter-price-group {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .report-date-group {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .filter-price {
    flex: 1;
  }

  .filter-date {
    flex: 1;
  }

  .filters-toolbar .filter-price .form-control {
    width: 100%;
    max-width: none;
  }

  .filters-toolbar .filter-date .form-control {
    width: 100%;
    max-width: none;
  }

  .filter-check {
    grid-column: 1 / -1;
  }
}

.catalog-preview-section {
  margin-bottom: 20px;
}

.catalog-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.catalog-preview-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.catalog-preview-range {
  margin: 0;
  font-size: 14px;
}

.catalog-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  margin-top: 4px;
}

.catalog-pager-status {
  min-width: 4.5rem;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}

.catalog-card {
  display: grid;
  grid-template-rows: 210px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.catalog-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.catalog-card--out-of-stock {
  opacity: 0.92;
}

.catalog-card--out-of-stock .catalog-card-media {
  filter: grayscale(0.35);
}

.catalog-card-body h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.catalog-stock-badge {
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.catalog-card-media {
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  background: #f8fafc;
}

.catalog-card-media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.catalog-card-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-weight: 700;
}

.catalog-card-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.catalog-card-body h3 {
  margin: 0;
  font-size: 20px;
}

.catalog-card-meta {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.catalog-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.catalog-card-stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.catalog-card-stats div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
}

.catalog-card-stats dt {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.catalog-card-stats dd {
  margin: 0;
}

.catalog-table-panel {
  margin-top: 8px;
}

.table-catalog .thumb-cell {
  width: 84px;
}

.thumb-cell {
  width: 72px;
}

.thumb-cell--sm {
  width: 56px;
}

.thumb-link {
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 68px;
  height: 68px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.thumb-link--sm {
  width: 48px;
  height: 48px;
}

.thumb-link img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.thumb-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-weight: 700;
}

.empty-panel {
  text-align: center;
}

.media-gallery {
  display: grid;
  gap: 14px;
}

.gallery-main {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f172a;
}

.gallery-slide {
  display: block;
  width: 100%;
  max-height: 520px;
  margin: 0 auto;
  object-fit: contain;
}

.gallery-slide.is-active {
  display: block;
}

.gallery-placeholder {
  display: grid;
  place-items: center;
  min-height: 360px;
  color: #cbd5e1;
  font-weight: 700;
}

.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gallery-thumb {
  overflow: hidden;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.gallery-thumb.is-active {
  border-color: var(--primary);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-actions {
  display: flex;
  gap: 10px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-value {
  border-color: #b8c7dc;
  background: #f8fbff;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
  gap: 18px;
}

.control-panel {
  min-height: 210px;
}

.control-panel:only-child {
  grid-column: 1 / -1;
}

.quality-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quality-item {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.quality-item span {
  color: var(--muted);
  font-weight: 700;
}

.quality-item strong {
  font-size: 30px;
}

.quality-item.ok {
  border-color: #bbf7d0;
}

.quality-item.warning {
  border-color: #facc15;
  background: #fffbeb;
}

.quality-item.neutral {
  border-color: #cbd5e1;
}

.compact-events {
  display: grid;
  gap: 8px;
}

.compact-events a {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.compact-events a:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.compact-events span,
.compact-events em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
}

.filters,
.form-grid,
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.filters {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.import-preview-panel,
.import-result-panel {
  margin-top: 18px;
}

.import-section-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.import-errors-title {
  margin: 16px 0 8px;
  font-size: 16px;
}

.import-result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 10px 16px;
  margin: 0;
}

.import-result-stats div {
  display: grid;
  gap: 4px;
}

.import-result-stats dt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.import-result-stats dd {
  margin: 0;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

label span,
.field-label {
  color: var(--secondary);
}

.wide {
  grid-column: 1 / -1;
}

.form-control,
.form-select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #b9c4d4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea.form-control {
  min-height: 112px;
  resize: vertical;
}

.form-check-input {
  width: 24px;
  height: 24px;
}

.form-actions {
  margin-top: 18px;
}

.form-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.form-section h2 {
  margin-bottom: 14px;
}

.form-panel .form-grid {
  align-items: start;
}

.form-panel .form-grid.form-grid-3col {
  align-items: end;
}

.combo-control {
  position: relative;
}

.native-dictionary-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.combo-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 9px 38px 9px 11px;
  border: 1px solid #b9c4d4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.combo-trigger::after {
  position: absolute;
  right: 14px;
  color: var(--muted);
  content: "⌄";
}

.combo-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-label.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.combo-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.combo-menu[hidden] {
  display: none;
}

.combo-options {
  display: grid;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.combo-option,
.combo-add {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.combo-option:hover,
.combo-option.selected {
  background: #eaf2fb;
  color: var(--primary-dark);
}

.combo-add {
  border-top: 1px solid var(--border);
  border-radius: 0;
  color: var(--primary);
}

.combo-add:hover {
  background: #f8fbff;
}

.combo-empty {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-weight: 600;
}

.tag-input-shell {
  position: relative;
}

.tag-input-shell .form-control {
  min-height: 44px;
}

.tag-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  max-height: 250px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.tag-suggestions[hidden] {
  display: none;
}

.tag-suggestion {
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.tag-suggestion:hover {
  background: #eaf2fb;
  color: var(--primary-dark);
}

.field-help {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table th,
.table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: var(--surface-soft);
  color: var(--secondary);
  font-size: 15px;
}

.table tr:hover td {
  background: #f8fbff;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus-visible td {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.strong-link {
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 2px 4px 2px 0;
  padding: 3px 9px;
  border-radius: 6px;
  background: #e8f0fb;
  color: #174680;
  font-size: 14px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.ok {
  background: #ecfdf3;
  color: #166534;
}

.status-pill.warning {
  background: #fffbeb;
  color: var(--warning);
}

.asset-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.asset-strip article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.asset-strip span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.asset-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.good {
  color: var(--success);
}

.warn {
  color: var(--warning);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.movement-details {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 10px 16px;
}

.movement-details > div {
  display: contents;
}

.table-row-link:hover {
  background: #f4f8fc;
}

.table-cover-link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}

.table-cover-link:hover {
  color: var(--primary-dark);
}

.filters-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
}

.filters-inline .form-actions {
  margin-top: 0;
}

.details {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 18px;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.details dd {
  margin: 0;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.files-readonly-note {
  margin: 0 0 12px;
}

.movement-product-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.movement-product-head p {
  margin: 4px 0 0;
}

.movement-history-panel {
  margin-top: 18px;
}

.movement-history-panel .section-head p {
  margin: 4px 0 0;
}

.movement-history-table td {
  vertical-align: middle;
}

.movement-form-panel {
  padding-bottom: 18px;
}

.movement-section {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.movement-section h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.movement-form-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.35fr) minmax(220px, 1.15fr) minmax(130px, .65fr);
  gap: 12px;
  align-items: end;
}

.movement-product-field,
.movement-unit-field,
.movement-wide-field {
  grid-column: span 2;
}

.movement-counterparty-field {
  grid-column: span 3;
}

.movement-writeoff-field,
.movement-notes-field {
  grid-column: 1 / -1;
}

.movement-inline-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--secondary);
  font-weight: 800;
}

.movement-inline-check .form-check-input {
  flex: 0 0 auto;
  margin: 0 10px 0 0;
}

.movement-inline-check span {
  color: var(--secondary);
  white-space: nowrap;
}

.attachment-form {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.attachment-fields {
  display: grid;
  gap: 12px;
}

.attachment-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.attachment-field .form-control,
.attachment-field .form-select,
.attachment-field input[type="file"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.attachment-submit {
  width: 100%;
  margin-top: 4px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
}

.detail-grid .attachment-form {
  overflow: hidden;
}

.attachment-formset {
  display: grid;
  gap: 12px;
}

.attachment-formset-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) minmax(220px, 1.2fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.attachment-formset-row input[type="file"] {
  padding: 6px 0;
}

.report-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-kpis {
  margin-top: 4px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.report-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-card .btn {
  align-self: end;
}

.file-tile {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
}

.file-tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.file-icon {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: #e5e7eb;
  color: var(--secondary);
  font-weight: 700;
}

.message-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.alert {
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #eff6ff;
}

.alert-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.alert-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.audit-details {
  grid-template-columns: 180px minmax(0, 1fr);
}

.break-word {
  overflow-wrap: anywhere;
}

.code-block {
  overflow: auto;
  max-height: 420px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
}

.audit-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(520px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

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

.modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.login-shell {
  display: grid;
  place-items: start center;
}

.login-panel {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel table {
  width: 100%;
  border-collapse: collapse;
}

.login-panel th,
.login-panel td {
  display: block;
  width: 100%;
  padding: 4px 0;
  text-align: left;
}

.login-panel input[type="text"],
.login-panel input[type="password"],
.login-panel input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #b9c4d4;
  border-radius: 6px;
  font: inherit;
}

.login-panel .btn {
  margin-top: 10px;
}

@media (max-width: 980px) {
  .page-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kpi-grid,
  .detail-grid,
  .control-grid,
  .audit-snapshot-grid,
  .asset-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters,
  .filters-grid-catalog,
  .form-grid,
  .mapping-grid,
  .movement-form-grid,
  .attachment-grid,
  .attachment-formset-row,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-field-wide {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .page {
    padding: 18px 12px 36px;
  }

  .kpi-grid,
  .detail-grid,
  .control-grid,
  .quality-list,
  .audit-snapshot-grid,
  .asset-strip,
  .filters,
  .form-grid,
  .mapping-grid,
  .movement-form-grid,
  .attachment-grid,
  .attachment-formset-row,
  .report-grid,
  .details {
    grid-template-columns: 1fr;
  }

  .btn,
  .actions,
  .form-actions {
    width: 100%;
  }

  .movement-product-field,
  .movement-unit-field,
  .movement-wide-field,
  .movement-counterparty-field,
  .movement-writeoff-field,
  .movement-notes-field {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
