* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f6f7fb;
  color: #1f2937;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.header {
  background: #111827;
  color: #fff;
  padding: 32px 0;
  margin-bottom: 24px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-main {
  min-width: 0;
}

.header-user {
  font-weight: 600;
  color: #f9fafb;
  font-size: 16px;
  white-space: nowrap;
}

.header-user[hidden] {
  display: none;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.subtitle {
  margin: 0;
  color: #d1d5db;
}

.catalog {
  padding-bottom: 40px;
}

.auth-page {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 40px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.auth-card h2 {
  margin: 0 0 16px;
  font-size: 24px;
  color: #111827;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: #111827;
}

.auth-field input {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}

.auth-submit {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-error {
  min-height: 18px;
  color: #dc2626;
  font-size: 14px;
}

.auth-switch {
  margin: 16px 0 0;
  font-size: 14px;
  color: #6b7280;
}

.auth-switch a {
  color: #111827;
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.header-user {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.header-logout {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.header-logout:hover {
  border-color: #fff;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 20% 80%;
  gap: 24px;
  align-items: start;
}

.sidebar {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.filters-panel {
  display: grid;
  gap: 16px;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.filters-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  color: #111827;
  gap: 12px;
}

.filters-actions {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  margin-left: auto;
}

.filters-header button {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}

.filters-reset {
  display: inline-flex;
  align-items: baseline;
  background: transparent;
  border: none;
  color: #0071c2;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: inherit;
}

.filters-apply {
  display: none;
  align-items: baseline;
  background: transparent;
  border: none;
  color: #0071c2;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: inherit;
}

body.filters-locked {
  overflow: hidden;
}

.filters-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #6b7280;
  display: none;
}

.content {
  grid-column: 2;
  min-width: 0;
}

.sort-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.sort-title {
  font-weight: 600;
  font-size: 15px;
  color: #111827;
}

.sort-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #1f2937;
}

.mobile-toolbar {
  display: none;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  margin-bottom: 16px;
}

.mobile-sort select {
  padding: 0;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  background: transparent;
  min-width: auto;
}

.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #111827;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
}

.filters-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.filters-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.filters-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.filter > span {
  font-weight: 600;
}

.filter:not(.price-filter) input,
.filter:not(.price-filter) select {
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  box-shadow: none;
}

.custom-select {
  position: relative;
}

.custom-select select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
}

.custom-select__button {
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  font-size: inherit;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.custom-select__button::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  transform: rotate(45deg);
  margin-left: auto;
}

.custom-select__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  border: 1px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  padding: 6px 0;
  max-height: 260px;
  overflow: auto;
  display: none;
  z-index: 20;
}

.custom-select__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: inherit;
  font-family: inherit;
  color: #1f2937;
  cursor: pointer;
}

.custom-select__option:hover {
  background: #f3f4f6;
}

.custom-select__option.is-selected {
  background: #e5effc;
  color: #0b5bd3;
}

.custom-select.is-open .custom-select__button {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-select.is-open .custom-select__list {
  display: block;
}

.custom-select--inline .custom-select__button {
  padding: 0;
  border: none;
  background: transparent;
  font-size: inherit;
  font-weight: 600;
}

.custom-select--inline .custom-select__button::after {
  border-right-color: #111827;
  border-bottom-color: #111827;
}

.price-filter {
  min-width: 200px;
}

.price-slider {
  position: relative;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  background: #fff;
}

.price-track {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
}

.price-track-fill {
  position: absolute;
  height: 100%;
  background: #0071c2;
  border-radius: 2px;
}

.price-input {
  position: absolute;
  left: 4px;
  right: 4px;
  width: calc(100% - 8px);
  height: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  outline: none;
  border: none;
  box-shadow: none;
}

.price-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  cursor: pointer;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #0071c2;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  margin-top: -6px;
}

.price-input::-moz-range-thumb {
  pointer-events: auto;
  cursor: pointer;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #0071c2;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.price-input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.price-input::-moz-range-track {
  height: 4px;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.price-input::-moz-range-progress {
  background: transparent;
  border: none;
  box-shadow: none;
}

.price-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

.stats {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

.filters-panel .stats {
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  padding-bottom: 40px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.card-competitor {
  background: #ffeb3b;
}

.card-link {
  text-decoration: none;
  color: inherit;
}

.card-price-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.card img {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  align-self: stretch;
}

.card .brand {
  font-weight: 700;
  text-transform: uppercase;
  color: #111827;
  font-size: 14px;
  padding: 6px 0;
  letter-spacing: 0.04em;
}

.card .model {
  font-size: 15px;
  font-weight: 600;
  min-height: 64px;
}

.card .price {
  font-size: 16px;
  font-weight: 700;
  color: #0f766e;
}

.empty {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  color: #6b7280;
}

.product-page {
  padding-bottom: 40px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #1f2937;
  text-decoration: none;
}

.product-title {
  margin: 0 0 24px;
  font-size: 28px;
  color: #111827;
}

.product-page h3 {
  margin: 0 0 12px;
}

.product-card {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 24px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.product-media img {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 12px;
}

.product-info {
  display: grid;
  gap: 16px;
}

.product-price-row {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

.analytics-link {
  text-decoration: none;
  color: #0071c2;
  font-weight: 600;
}

.product-details {
  display: grid;
  gap: 10px;
}

.product-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

.product-detail-label {
  color: #6b7280;
}

.product-detail-value {
  font-weight: 600;
  color: #111827;
  text-align: right;
}

.product-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.image-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-card img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 10px;
}

.image-caption {
  font-size: 13px;
  color: #6b7280;
}

.product-prices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.product-price {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.price-value {
  font-size: 20px;
  font-weight: 700;
  color: #0f766e;
}

.price-formula-grid {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: #374151;
}

.price-formula-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.price-formula-row.is-final .price-formula-value {
  font-weight: 700;
  color: #111827;
}

.price-formula-label {
  color: #6b7280;
}

.price-formula-value {
  font-weight: 600;
  color: #1f2937;
}

.product-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

@media (max-width: 900px) {
  .product-card {
    grid-template-columns: 1fr;
  }

  .product-price-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .product-prices {
    grid-template-columns: 1fr;
  }
}

.product-column {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.price-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.price-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.price-items a {
  color: #1f2937;
  text-decoration: none;
  font-weight: 600;
}

.price-subtitle {
  margin: 12px 0 8px;
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-page {
  padding-bottom: 40px;
}

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

.admin-column h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #111827;
}

.admin-actions {
  display: grid;
  gap: 12px;
}

.admin-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-meta {
  font-size: 12px;
  color: #6b7280;
}



.admin-btn {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #111827;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.admin-btn:hover {
  background: #1f2937;
}

.admin-status {
  margin-top: 16px;
  color: #374151;
}

.admin-status.success {
  color: #047857;
}

.admin-status.error {
  color: #b91c1c;
}

.admin-warning-title {
  margin-top: 8px;
  color: #b45309;
  font-weight: 600;
}

.admin-warning-item {
  color: #92400e;
  font-size: 13px;
}

.admin-warning-more {
  color: #92400e;
  font-size: 12px;
}

@media (max-width: 900px) {
  .catalog-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 0;
  }

  .header {
    margin-bottom: 16px;
  }

  .sidebar {
    display: block;
  }

  .sort-group {
    display: none;
  }

  .filters-panel {
    position: fixed;
    inset: 16px 16px auto 16px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    display: none;
    z-index: 1001;
    gap: 8px;
  }

  .filters-close {
    position: absolute;
    top: 6px;
    right: 6px;
  }

  .filters-panel.is-open {
    display: grid;
  }

  .filters-close {
    display: inline-flex;
  }

  .filters-apply {
    display: inline-flex;
  }

  .content {
    grid-column: 1;
    grid-row: auto;
  }

  .mobile-toolbar {
    display: flex;
  }

  .stats {
    margin-top: 0;
  }

  .admin-columns {
    grid-template-columns: 1fr;
  }
 
}

@media (max-width: 600px) {

  .grid {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .card {
    width: 100%;
  }

  .card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    align-self: stretch;
  }

  .card .model {
    min-height: 40px;
  }
}

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