body {
  background: #f6f7f9;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #d8dee6;
}

.catalog-panel {
  min-width: 0;
  padding: 16px;
}

/* Категории и действия — на одном уровне; при нехватке места переносятся
   вниз плитка за плиткой, кнопки действий прижаты вправо. */
.catalog-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* nav не создаёт собственный бокс — плитки становятся элементами .catalog-bar. */
.category-tabs {
  display: contents;
}

.category-tab {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  color: #344054;
  display: flex;
  font-size: 13px;
  justify-content: center;
  line-height: 1.15;
  min-height: 35px;
  min-width: 92px;
  padding: 5px 10px;
  text-align: center;
  white-space: nowrap;
}

.category-tab:hover {
  background: #f1f5f9;
}

.category-tab.active {
  background: #0b5ed7;
  border-color: #0b5ed7;
  color: #ffffff;
  font-weight: 600;
}

.table-wrap {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  overflow: auto;
  max-height: calc(100vh - 280px);
}

.catalog-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
  margin-bottom: 0;
}

/* Ячейки данных подстраиваются под содержимое, но не шире максимума:
   длинные значения обрезаются многоточием и не растягивают таблицу. */
.catalog-table td {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-table td.price-cell {
  cursor: help;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.price-tooltip {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.2);
  display: none;
  font-family: var(--bs-body-font-family);
  font-size: 13px;
  max-width: min(420px, calc(100vw - 16px));
  min-width: 260px;
  padding: 10px 12px;
  pointer-events: none;
  position: fixed;
  white-space: normal;
  z-index: 2000;
}

.price-tooltip.show {
  display: block;
}

.price-tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.price-tooltip-row {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 3px 0;
}

.price-tooltip-row strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price-tooltip-details {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
}

.price-tooltip-details small {
  color: #667085;
  font-family: inherit;
  font-size: inherit;
  white-space: nowrap;
}

.catalog-table td.validation-cell {
  cursor: help;
  overflow: visible;
}

.validation-badge {
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 3px 8px;
  white-space: nowrap;
}

.validation-valid {
  background: #e7f6ec;
  border-color: #a6d9b5;
  color: #146c2e;
}

.validation-invalid {
  background: #fff1f0;
  border-color: #f2b8b5;
  color: #a61b1b;
}

.validation-tooltip {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.2);
  display: none;
  font-family: var(--bs-body-font-family);
  font-size: 13px;
  max-width: min(520px, calc(100vw - 16px));
  min-width: 300px;
  padding: 10px 12px;
  pointer-events: none;
  position: fixed;
  white-space: normal;
  z-index: 2000;
}

.validation-tooltip.show {
  display: block;
}

.validation-tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.validation-tooltip-error + .validation-tooltip-error {
  border-top: 1px solid #e4e7ec;
  margin-top: 8px;
  padding-top: 8px;
}

.validation-tooltip-field {
  font-weight: 600;
  margin-bottom: 2px;
}

.validation-tooltip-date,
.validation-tooltip-empty {
  color: #667085;
  margin-top: 4px;
}

.catalog-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f3f5;
  vertical-align: top;
}

.filter-input {
  min-width: 0;
  width: 100%;
  font-size: 12px;
}

.selected-row td {
  background: #fff3cd !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
}

.muted-small {
  color: #667085;
  font-size: 12px;
}

.req {
  color: #d6336c;
  margin-left: 2px;
}

/* Собственный оверлей-модалка (без Bootstrap JS). */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  z-index: 1050;
}

.modal-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.2);
  width: min(1320px, 100%);
  margin: auto;
}

.modal-card-sm {
  width: min(460px, 100%);
}

.modal-head {
  align-items: center;
  border-bottom: 1px solid #e4e7ec;
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
}

.modal-body {
  padding: 20px;
}

.form-section {
  border: 1px solid #e4e7ec;
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px 16px;
}

.form-section > legend {
  float: none;
  width: auto;
  padding: 0 6px;
  margin-bottom: 8px;
}

/* Адаптивная сетка полей формы: 6 колонок → 4 → 3 → 2 → 1. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 16px;
}

/* Длинные поля (например, Описание) занимают всю ширину сетки. */
.field-wide {
  grid-column: 1 / -1;
}

.field-row textarea {
  resize: vertical;
}

.structured-editor {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 0.75rem;
}

.structured-items,
.structured-object {
  display: grid;
  gap: 0.75rem;
}

.structured-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: start;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.structured-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.structured-property > .form-label {
  margin-bottom: 0.25rem;
}

@media (max-width: 1400px) {
  .field-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

@media (max-width: 800px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.controls-compact .form-label {
  font-size: 12px;
  margin-bottom: 2px;
}

.col-check {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-size: 14px;
  gap: 8px;
  margin: 0;
}

@media (max-width: 900px) {
  .table-wrap {
    max-height: calc(100vh - 320px);
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .category-tab {
    font-size: 12px;
    min-height: 31px;
    min-width: 72px;
    padding: 4px 8px;
  }
}
