
:root {
  color-scheme: light;
  --bg: #fff;
  --card: #fff;
  --line: #dfe3e8;
  --text: #1f2937;
  --muted: #667085;
  --accent: #2563eb;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.catalog-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

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

.catalog-header h1 {
  margin: 0 0 5px;
  font-size: 28px;
}

.catalog-header p {
  margin: 0;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 150px 180px 130px;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}

.controls input,
.controls select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font: inherit;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

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

.item-card {
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e5e7eb;
  cursor: pointer;
}

.preview-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.preview-state.error {
  color: #b42318;
  background: rgba(255,255,255,.82);
}

.item-info {
  padding: 12px;
}

.item-name {
  margin: 0 0 9px;
  min-height: 2.45em;
  line-height: 1.22;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.meta {
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meta-label { color: var(--muted); }

.meta-value {
  text-align: right;
  overflow-wrap: anywhere;
}

.item-id {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 22px 0 4px;
}

.pagination button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: .45;
  cursor: default;
}

.page-number {
  min-width: 120px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 760px) {
  .catalog-shell { padding: 14px; }
  .catalog-header { display: block; }
  .controls {
    grid-template-columns: minmax(240px, 1fr) 135px 160px 120px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .item-info { padding: 9px; }
  .item-name { font-size: 14px; }
}

@media (max-width: 460px) {
  .catalog-grid { grid-template-columns: 1fr 1fr; }
}

body.lightbox-open {
  overflow: hidden;
  padding-right: var(--lightbox-scrollbar-width, 0px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .72);
}

.lightbox-panel {
  width: min(1080px, 96vw);
  max-height: 94vh;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .32);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.lightbox-header h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.lightbox-id {
  color: var(--muted);
  font-size: 12px;
}

.lightbox-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-stage {
  position: relative;
  max-width: 96vw;
  max-height: calc(94vh - 70px);
  margin: 0 auto;
  overflow: auto;
  background: #e5e7eb;
}

.lightbox-stage canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0 auto;
}

.lightbox-state[hidden] {
  display: none;
}

.lightbox-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, .7);
  pointer-events: none;
}

@media (max-width: 760px) {
  .lightbox { padding: 10px; }
  .lightbox-panel { width: 100%; }
  .lightbox-header { padding: 10px 12px; }
}
