:root {
  --paper: #fbfaf6;
  --panel: #ffffff;
  --ink: #171916;
  --muted: #686d65;
  --line: #dedbd2;
  --sage: #5b7463;
  --sage-dark: #263f30;
  --blue: #315f7d;
  --coral: #b95e4b;
  --gold: #c79a3d;
  --shadow: 0 18px 55px rgba(23, 25, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(91, 116, 99, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(185, 94, 75, 0.16), transparent 38%),
    var(--paper);
  font-family: "Noto Sans SC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.86);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  background: var(--sage-dark);
  border-radius: 6px;
  font-family: "Fraunces", serif;
  font-weight: 650;
}

.brand h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 25px;
  letter-spacing: 0;
}

.brand p,
#viewMeta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.metric strong {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 28px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  padding-top: 10px;
}

.panel-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.category-button:hover,
.category-button.is-active {
  border-color: var(--sage);
  background: #eef3ed;
}

.category-count {
  min-width: 30px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--sage);
  text-align: center;
  font-size: 12px;
}

.workspace {
  padding: 24px 30px 36px;
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-52%);
}

#searchInput,
#sortSelect {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

#searchInput {
  height: 44px;
  padding: 0 16px 0 40px;
}

#sortSelect {
  height: 40px;
  padding: 0 12px;
}

#sortSelect {
  width: min(360px, 42vw);
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button,
.export-button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 13px;
  white-space: nowrap;
}

.segmented button.is-active {
  color: #fff;
  background: var(--blue);
}

.export-button {
  border: 1px solid var(--sage-dark);
  color: #fff;
  background: var(--sage-dark);
}

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

.content-head h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 38px;
  letter-spacing: 0;
  white-space: nowrap;
}

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

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(23, 25, 22, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.image-frame {
  aspect-ratio: 1 / 1;
  background: #f1efe8;
  overflow: hidden;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 14px;
}

.card-topline,
.variant-row,
.dialog-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--sage);
  font-size: 12px;
  line-height: 1;
}

.badge.blue {
  background: var(--blue);
}

.badge.coral {
  background: var(--coral);
}

.product-title {
  display: -webkit-box;
  min-height: 60px;
  margin: 10px 0 12px;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.product-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: min(840px, calc(100vh - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
}

.product-dialog::backdrop {
  background: rgba(23, 25, 22, 0.48);
}

.close-button {
  position: absolute;
  right: 14px;
  top: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.dialog-body {
  display: grid;
  grid-template-columns: 42% 58%;
  min-height: 560px;
}

.dialog-gallery {
  padding: 20px;
  background: #f3f0e8;
}

.dialog-gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.thumbs img {
  aspect-ratio: 1 / 1;
}

.dialog-info {
  padding: 30px 30px 24px;
  overflow: auto;
}

.dialog-info h3 {
  margin: 0 40px 14px 0;
  font-size: 23px;
  line-height: 1.25;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--sage-dark);
  background: #f7f7f2;
  font-size: 12px;
}

.variant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.variant-table th,
.variant-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.variant-table th {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 60px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .content-head {
    align-items: stretch;
    flex-direction: column;
  }

  #sortSelect {
    width: 100%;
  }

  .dialog-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

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

  .content-head h2 {
    font-size: 30px;
  }

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