:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e6e7eb;
  --border-strong: #d0d3da;
  --text: #111317;
  --text-muted: #5e6472;
  --accent: #111317;
  --accent-soft: #f0f1f4;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(17, 19, 23, 0.04);
  --shadow-md: 0 10px 30px rgba(17, 19, 23, 0.08);
  --shadow-lg: 0 24px 60px rgba(17, 19, 23, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.view-toggle {
  display: inline-flex;
  background: var(--accent-soft);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.toggle-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Controls */
.controls-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.controls-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-wrap {
  position: relative;
  flex: 1 1 300px;
  min-width: 240px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 19, 23, 0.08);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

select {
  height: 42px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
}

.checkbox-pill input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  margin: 0;
}

.clear-btn {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.clear-btn:hover {
  background: #e4e6ec;
}

/* Main Grid */
.main-content {
  padding-top: 22px;
  padding-bottom: 64px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-bottom: 1px solid #f0f1f4;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.placeholder-box {
  width: 100%;
  height: 100%;
  background: #f4f5f7;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #8c93a3;
  padding: 12px;
  text-align: center;
}

.placeholder-box svg {
  width: 34px;
  height: 34px;
  opacity: 0.55;
}

.placeholder-sku {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #7b8291;
}

.qty-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(17, 19, 23, 0.86);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-sku {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.size-pills {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.size-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
}

.mysku-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.73rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: #eef2ff;
  color: #2b3a67;
}

/* Empty & Load More */
.empty-state {
  text-align: center;
  padding: 72px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.empty-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.empty-sub {
  margin: 8px 0 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.primary-btn,
.secondary-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
  border: 0;
}

.secondary-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.secondary-btn:hover {
  background: var(--accent-soft);
}

.load-more-wrap {
  margin-top: 28px;
  text-align: center;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 23, 0.56);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: #e2e4ea;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 28px;
  align-items: start;
}

.modal-media {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-sku-row {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mono-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
}

.copy-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--accent-soft);
}

.modal-info h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.modal-count {
  margin: 0 0 16px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.pairs-list-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--border);
}

.pairs-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}

.pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid #f0f1f4;
  gap: 12px;
}

.pair-row:last-child {
  border-bottom: 0;
}

.pair-size {
  font-weight: 600;
  font-size: 0.92rem;
}

.pair-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111317;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 200;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .modal-body {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 12px;
  }
}
