:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #155eef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.container {
  width: min(1180px, 92vw);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  letter-spacing: 0;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.count {
  color: var(--muted);
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.5fr minmax(160px, 0.7fr);
  gap: 0.75rem;
  padding: 1.2rem 0;
}

input,
select {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
  gap: 1rem;
  padding: 0 0 2rem;
}

.item-card {
  display: flex;
  flex-direction: column;
  height: 34rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.item-card:hover {
  border-color: #b9c4d5;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.item-card:focus-visible {
  outline: 3px solid rgba(21, 94, 239, 0.22);
  outline-offset: 3px;
}

.item-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #eef2f6;
  color: var(--muted);
  font-weight: 800;
}

.item-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0.95rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.item-title {
  margin: 0.45rem 0 0.4rem;
  min-height: 2.6rem;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.price {
  margin: 0 0 0.65rem;
  font-size: 1.08rem;
  font-weight: 850;
}

.description {
  height: 7.1rem;
  margin: 0 0 0.8rem;
  overflow: hidden;
  color: #475467;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-line;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: auto;
}

.links a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.item-dialog {
  width: min(920px, 94vw);
  max-height: min(86vh, 920px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.item-dialog::backdrop {
  background: rgba(15, 23, 42, 0.54);
}

.dialog-panel {
  position: relative;
  max-height: min(86vh, 920px);
  overflow: auto;
  background: var(--surface);
}

.dialog-close {
  position: sticky;
  top: 0.7rem;
  left: calc(100% - 3rem);
  z-index: 2;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.dialog-content {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(260px, 1.05fr);
  gap: 1.25rem;
  padding: 1.25rem;
}

.dialog-image {
  display: grid;
  gap: 0.7rem;
}

.dialog-image img {
  width: 100%;
  border-radius: 8px;
  background: #eef2f6;
}

.dialog-body h2 {
  margin: 0.25rem 0 0.65rem;
  font-size: 1.5rem;
  line-height: 1.2;
}

.dialog-description {
  margin: 0 0 1rem;
  color: #475467;
  line-height: 1.58;
  white-space: pre-line;
}

.empty {
  display: none;
  padding: 2rem 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .header-inner {
    display: block;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .item-card {
    height: 33rem;
  }

  .dialog-content {
    grid-template-columns: 1fr;
  }
}
