* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: #0f1419;
  color: #e7e9ea;
  min-height: 100vh;
  line-height: 1.5;
}

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

.wrap {
  width: 100%;
  max-width: min(1920px, 98vw);
  margin: 0 auto;
  padding: 0.75rem clamp(0.75rem, 2vw, 1.5rem);
}

.filter-select {
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #192734;
  color: #e7e9ea;
  min-width: 140px;
}

.header {
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
}

.subtitle {
  color: #8b98a5;
  margin: 0;
  font-size: 0.95rem;
}

.subtitle a {
  color: #1d9bf0;
  text-decoration: none;
}

.subtitle a:hover {
  text-decoration: underline;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar-main-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-main-row .search-input {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.toolbar-main-row .filter-category,
.toolbar-main-row .filter-subcategory {
  min-width: 140px;
}

.filter-dim-label {
  font-size: 0.9rem;
  color: #8b98a5;
  margin: 0 0.15rem 0 0.5rem;
}
.filter-dim-input {
  width: 4rem;
  padding: 0.5rem 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #192734;
  color: #e7e9ea;
  outline: none;
}
.filter-dim-input::placeholder {
  color: #6e767d;
}
.filter-dim-input:focus {
  border-color: #1d9bf0;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.search-input {
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  border: 1px solid #38444d;
  border-radius: 8px;
  background: #192734;
  color: #e7e9ea;
  outline: none;
}

.search-input::placeholder {
  color: #6e767d;
}

.search-input:focus {
  border-color: #1d9bf0;
  box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.refresh-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #8b98a5;
  cursor: pointer;
}
.refresh-option input { cursor: pointer; }

.btn-primary {
  background: #1d9bf0;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1a8cd8;
}

.btn-outline {
  background: transparent;
  border: 1px solid #38444d;
  color: #e7e9ea;
}

.btn-outline:hover {
  background: #192734;
  border-color: #1d9bf0;
}

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

.data-actions .label {
  color: #8b98a5;
  font-size: 0.9rem;
  margin-right: 0.25rem;
}

.import-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.import-status {
  font-size: 0.85rem;
  color: #8b98a5;
}

.import-status.error {
  color: #f4212e;
}

.import-status.ok {
  color: #00ba7c;
}

.parse-status-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.parse-status-block .label {
  color: #8b98a5;
  font-size: 0.9rem;
}
.parse-raw-count {
  color: #8b98a5;
  font-size: 0.9rem;
}
.parse-status-block .btn-sm {
  margin-left: 0.25rem;
}
.ui-version {
  font-size: 0.75rem;
  color: #657786;
  margin-left: 0.5rem;
}

.loading {
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #192734;
  color: #1d9bf0;
}

.status-panel {
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
  background: #192734;
  border: 1px solid #38444d;
}

.status-panel.hidden {
  display: none !important;
}

.progress-bar {
  height: 4px;
  background: #38444d;
  overflow: hidden;
}

.progress-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  background: #1d9bf0;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

.progress-bar.hidden {
  display: none !important;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.status-msg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: #8b98a5;
}

.status-msg.ok {
  color: #00ba7c;
}

.status-msg.error {
  color: #f4212e;
}

.status-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
}

.status-close:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
}

.hidden {
  display: none !important;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  background: #192734;
  border: 1px solid #38444d;
  border-radius: 10px;
  padding: 1rem 1.15rem;
}

.card h3 {
  margin: 0 0 0.35rem 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card .description {
  color: #8b98a5;
  font-size: 0.9rem;
  margin: 0.35rem 0;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #6e767d;
}

.card .price {
  color: #00ba7c;
  font-weight: 600;
}

.card a.url {
  color: #1d9bf0;
  text-decoration: none;
}

.card a.url:hover {
  text-decoration: underline;
}

.unit-switcher-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid #38444d;
}
.unit-switcher-inline label {
  color: #8b98a5;
  font-size: 0.9rem;
}
.unit-switcher-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.unit-switcher-row label {
  color: #8b98a5;
  font-size: 0.9rem;
}

.progress-detail {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: #8b98a5;
}
.progress-detail.hidden {
  display: none !important;
}
.progress-detail-bar {
  height: 8px;
  background: #38444d;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}
.progress-detail-fill {
  height: 100%;
  background: #1d9bf0;
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s ease;
}
.progress-detail-text {
  display: block;
  font-size: 0.85rem;
}
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.price-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #192734;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #38444d;
}

.price-table th,
.price-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #38444d;
}

.price-table th {
  background: #22303c;
  color: #8b98a5;
  font-weight: 600;
}

.price-table tbody tr:hover {
  background: #22303c;
}

.price-table .price-cell {
  color: #00ba7c;
  font-weight: 600;
  white-space: nowrap;
}

.price-table .name-cell {
  min-width: 200px;
  max-width: 35vw;
}

.price-table .specs-cell {
  max-width: 220px;
  font-size: 0.85rem;
  color: #8b98a5;
}

.price-table a {
  color: #1d9bf0;
  text-decoration: none;
}

.price-table a:hover {
  text-decoration: underline;
}

.link-btn {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  color: #1d9bf0;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.cart-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0.1rem 0.35rem;
  margin-left: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #1d9bf0;
  color: #fff;
  border-radius: 10px;
}

.price-table .th-cart {
  width: 1%;
  min-width: 6rem;
  white-space: nowrap;
}

/* Правые колонки (ссылка →, Варианты, В корзину) всегда видны при горизонтальной прокрутке */
.price-table th:nth-last-child(1),
.price-table td:nth-last-child(1) {
  position: sticky;
  right: 0;
  min-width: 6rem;
  background: #192734;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.15);
  z-index: 2;
  white-space: nowrap;
}
.price-table th:nth-last-child(1) { background: #22303c; }
.price-table tbody tr:hover td:nth-last-child(1) { background: #22303c; }

.price-table th:nth-last-child(2),
.price-table td:nth-last-child(2) {
  position: sticky;
  right: 6rem;
  min-width: 6.5rem;
  background: #192734;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.12);
  z-index: 2;
  white-space: nowrap;
}
.price-table th:nth-last-child(2) { background: #22303c; }
.price-table tbody tr:hover td:nth-last-child(2) { background: #22303c; }

.price-table th:nth-last-child(3),
.price-table td:nth-last-child(3) {
  position: sticky;
  right: 12.5rem;
  min-width: 2.5rem;
  background: #192734;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.08);
  z-index: 2;
}
.price-table th:nth-last-child(3) { background: #22303c; }
.price-table tbody tr:hover td:nth-last-child(3) { background: #22303c; }

.price-table thead .filter-row th {
  background: #192734;
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.price-table .th-filter .filter-input,
.price-table .th-filter .filter-select {
  width: 100%;
  max-width: 100%;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
  background: #22303c;
  border: 1px solid #38444d;
  border-radius: 4px;
  color: #e7e9ea;
  box-sizing: border-box;
}

.price-table .th-filter .filter-price {
  width: 4rem;
  max-width: 100%;
}

.price-table .th-filter .filter-price + .filter-price {
  margin-left: 0.25rem;
}

.btn-cart-add,
.btn-variants-open {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
}
.btn-variants-open {
  min-width: 5rem;
}
.btn-cart-add {
  min-width: 5rem;
}

.name-cell-clickable {
  cursor: pointer;
}
.name-cell-clickable:hover {
  text-decoration: underline;
}

.main-and-cart {
  position: relative;
  flex: 1;
  min-width: 0;
  display: block;
}

.main-and-cart .results {
  margin-right: 0;
  transition: margin-right 0.25s ease;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.main-and-cart.cart-open .results {
  margin-right: 340px;
}

.main-and-cart .table-wrap {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: #192734;
  border-left: 1px solid #38444d;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.35);
  z-index: 100;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s ease;
}

.cart-panel.open {
  transform: translateX(0);
  visibility: visible;
}

.cart-panel-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #38444d;
  flex-shrink: 0;
  gap: 0.5rem;
}

.cart-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  flex: 1;
}

.cart-panel-close-btn,
.cart-panel-header .modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  background: #38444d;
  border: none;
  border-radius: 6px;
  color: #e7e9ea;
}
.cart-panel-close-btn:hover,
.cart-panel-header .modal-close:hover {
  background: #5c6b7a;
  color: #fff;
}

.cart-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background: #192734;
}

.cart-empty {
  color: #8b98a5;
  font-size: 0.95rem;
  margin: 0;
}

.cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cart-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid #38444d;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
}

.cart-item-meta {
  font-size: 0.8rem;
  color: #8b98a5;
}

.cart-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cart-qty-input {
  width: 4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #0f1419;
  color: #e7e9ea;
  text-align: right;
}

.cart-item-row .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.cart-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #38444d;
  flex-shrink: 0;
  background: #192734;
}

.cart-footer .btn {
  width: 100%;
}

.cart-total-weight {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid #38444d;
  font-weight: 600;
  color: #00ba7c;
}

.cart-item-weight,
.cart-item-price,
.cart-item-sum {
  font-size: 0.8rem;
  color: #8b98a5;
}

.cart-item-sum {
  color: #00ba7c;
  font-weight: 600;
}

.cart-item-unit {
  width: 5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #0f1419;
  color: #e7e9ea;
}

.price-table .weight-cell {
  white-space: nowrap;
  color: #8b98a5;
  font-size: 0.85rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden {
  display: none !important;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.modal-content {
  position: relative;
  background: #192734;
  border: 1px solid #38444d;
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}
.variant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #38444d;
}
.variant-row:last-child { border-bottom: none; }
.variant-dims { flex: 1 1 180px; font-size: 0.9rem; }
.variant-price { font-size: 0.9rem; color: #8b98a5; }
.variant-qty-input { width: 4rem; padding: 0.25rem; text-align: right; }
.modal-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}
.modal-name {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  color: #8b98a5;
}
.modal-form label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: #8b98a5;
}
.modal-form input,
.modal-form select {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #22303c;
  color: #e7e9ea;
}
.modal-form select {
  width: auto;
  min-width: 120px;
}
.modal-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.5rem;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
}

.pagination-bar .total-info,
.pagination-bar .page-info {
  font-size: 0.9rem;
  color: #8b98a5;
}

.pagination-bar .btn-outline {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.empty {
  text-align: center;
  padding: 2rem;
  color: #8b98a5;
  background: #192734;
  border-radius: 10px;
  border: 1px dashed #38444d;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-screen.hidden {
  display: none;
}
.login-box {
  width: 100%;
  max-width: 320px;
  padding: 2rem;
  background: #192734;
  border: 1px solid #38444d;
  border-radius: 12px;
}
.login-box h2 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
}
.login-box label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: #8b98a5;
}
.login-box input {
  width: 100%;
  padding: 0.6rem;
  font-size: 1rem;
  border: 1px solid #38444d;
  border-radius: 6px;
  background: #22303c;
  color: #e7e9ea;
  margin-bottom: 0.5rem;
}
.login-box .btn {
  width: 100%;
  margin-top: 1rem;
}
.login-link {
  margin-top: 1.25rem;
  font-size: 0.9rem;
}
.login-link a {
  color: #1d9bf0;
  text-decoration: none;
}
.login-link a:hover {
  text-decoration: underline;
}
.login-error {
  color: #f4212e;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.login-success {
  color: #00ba7c;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.header-user #header-username {
  font-size: 0.9rem;
  color: #8b98a5;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.cabinet-stats p { margin: 0.5rem 0; }
.cabinet-msg { font-size: 0.9rem; margin-top: 0.5rem; }
.cabinet-msg.ok { color: #00ba7c; }
.cabinet-msg.error { color: #f4212e; }
.cabinet-admin-section { margin-top: 1rem; }
.cabinet-admin-section h4 { margin: 1rem 0 0.5rem 0; }
.users-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.9rem; }
.users-table th, .users-table td { padding: 0.4rem 0.5rem; text-align: left; border-bottom: 1px solid #38444d; }
#cabinet-create-user input { margin-right: 0.5rem; margin-bottom: 0.5rem; padding: 0.4rem; }
.modal-close { position: absolute; top: 0.5rem; right: 0.75rem; background: none; border: none; color: #8b98a5; font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: #e7e9ea; }

/* Rollback snapshots modal */
.rollback-hint {
  font-size: 0.9rem;
  color: #8b98a5;
  margin-bottom: 1rem;
}
.rollback-list {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 1rem;
}
.rollback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #38444d;
  font-size: 0.9rem;
}
.rollback-row:last-child { border-bottom: none; }
.rollback-row-btn { flex-shrink: 0; }
.rollback-empty {
  padding: 1rem;
  color: #8b98a5;
  text-align: center;
}
.rollback-message {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
}
.rollback-message.ok { background: rgba(0, 186, 124, 0.15); color: #00ba7c; }
.rollback-message.error { background: rgba(244, 33, 46, 0.15); color: #f4212e; }

/* Agent chat */
.agent-chat-content { max-width: 560px; max-height: 85vh; display: flex; flex-direction: column; }
.agent-chat-hint { font-size: 0.85rem; color: #8b98a5; margin-bottom: 0.75rem; }
.agent-chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
  border: 1px solid #38444d;
  border-radius: 8px;
  background: #22303c;
}
.agent-msg { margin: 0.5rem 0.75rem; }
.agent-msg-user { text-align: right; }
.agent-msg-user .agent-msg-text { display: inline-block; text-align: left; padding: 0.5rem 0.75rem; background: #1d9bf0; color: #fff; border-radius: 12px; max-width: 85%; }
.agent-msg-assistant .agent-msg-text { padding: 0.5rem 0.75rem; background: #38444d; border-radius: 12px; color: #e7e9ea; }
.agent-msg-text { white-space: pre-wrap; word-break: break-word; font-size: 0.95rem; }
.agent-chat-input-wrap { display: flex; gap: 0.5rem; align-items: flex-end; }
.agent-chat-input { flex: 1; padding: 0.5rem; font-size: 0.95rem; border: 1px solid #38444d; border-radius: 8px; background: #22303c; color: #e7e9ea; resize: vertical; min-height: 44px; }
.agent-chat-input:focus { outline: none; border-color: #1d9bf0; }
.agent-chat-input-wrap .btn { flex-shrink: 0; }
.agent-chat-error { font-size: 0.9rem; color: #f4212e; margin-top: 0.5rem; }
