:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #eef3f6;
  --text: #182028;
  --muted: #66717d;
  --line: #dbe3ea;
  --accent: #2f7d65;
  --accent-strong: #1f5f4c;
  --warn: #a65122;
  --shadow: 0 18px 45px rgba(35, 47, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-strong);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  font-weight: 760;
}

.status {
  max-width: 360px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.language-picker {
  width: 150px;
}

.language-picker select {
  height: 38px;
}

.status.error {
  color: var(--warn);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 0 14px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 101, 0.14);
}

.summary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 22px 0 14px;
  color: var(--muted);
}

.summary strong {
  color: var(--text);
  font-size: 24px;
}

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

.item-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(35, 47, 61, 0.06);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.item-card:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 125, 101, 0.38);
  box-shadow: var(--shadow);
}

.item-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #e8eef1, #f8fafb);
}

.item-card-body {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.item-title {
  min-height: 42px;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.item-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.price {
  color: var(--accent-strong);
  font-weight: 760;
}

.category-pill {
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.item-dialog {
  width: min(860px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.item-dialog::backdrop {
  background: rgba(16, 24, 32, 0.5);
}

.icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) 1fr;
}

.dialog-gallery {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  background: var(--surface-strong);
}

.dialog-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #e8eef1;
}

.thumbnail-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
}

.thumbnail {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.thumbnail.active {
  border-color: var(--accent);
}

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

.dialog-details {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 30px;
}

.dialog-details h2 {
  padding-right: 36px;
  font-size: 26px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.description {
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}

.detail span {
  color: var(--muted);
  font-size: 12px;
}

.detail strong {
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .language-picker {
    width: min(220px, 100%);
  }

  .status {
    text-align: left;
  }

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

  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .item-card-body {
    padding: 10px;
  }

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

  .dialog-image {
    max-height: 360px;
  }

  .dialog-details {
    padding: 22px;
  }

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

@media (max-width: 420px) {
  main {
    width: min(100% - 20px, 1180px);
  }

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