:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #5c5954;
  --border: #e2dfd8;
  --accent: #1f5c4a;
  --accent-soft: #e8f1ef;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  padding: 24px 16px 48px;
}
.container {
  max-width: 1080px;
  margin: 0 auto;
}
header {
  padding-bottom: 0;
}
h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}
.header-notes {
  margin: 16px 0 0;
  padding-left: 1.15em;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 52rem;
}
.header-notes li {
  margin: 0.35em 0;
}
.header-notes li + li {
  margin-top: 0.5em;
}
.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0 20px;
  flex-wrap: wrap;
}
.search {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
}
.search:focus {
  outline: none;
  border-color: var(--accent);
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active, .chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.name {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
}
.prices {
  text-align: right;
  white-space: nowrap;
  line-height: 1.3;
}
.price-pack {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
.price-detail {
  font-size: 0.82rem;
  color: var(--muted);
}
.meta-line {
  font-size: 0.85rem;
  color: var(--muted);
}
.desc {
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 4px;
}
.category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-top: 2px;
}
.no-results {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* View toggle */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
}
.view-btn {
  background: var(--surface);
  border: none;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.view-btn + .view-btn {
  border-left: 1px solid var(--border);
}
.view-btn.active {
  background: var(--accent);
  color: white;
}

/* Photo button */
.photo-btn {
  padding: 4px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.photo-btn svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.photo-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.photo-btn:hover svg {
  color: var(--accent);
}

/* Expand/collapse icon for list rows with details */
.expand-icon {
  line-height: 1;
  cursor: pointer;
  user-select: none;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.1s;
}
.expand-icon svg {
  width: 16px;
  height: 16px;
}
.expand-icon:hover {
  color: var(--accent);
}

/* List view */
#grid.list-view {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.list-row {
  display: grid;
  grid-template-columns: 80px 2.5fr 78px 62px 55px 62px 28px;
  align-items: center;
  gap: 4px 6px;
  padding: 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  cursor: pointer;
}
.list-row:last-child {
  border-bottom: none;
}
.list-row:hover {
  background: #fbfaf7;
}
.list-row .cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  text-align: center;
}
.list-row .name {
  font-weight: 500;
}
.list-row .price,
.list-row .detail {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.list-row .price {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
}
.list-row .detail {
  font-size: 0.78rem;
  color: var(--muted);
}
.list-row .actions {
  text-align: right;
}

/* Detailed list mode: show descriptions inline and photo icons */
#grid.detailed .list-row {
  align-items: center;
  grid-template-columns: 80px 3fr 78px 62px 55px 62px 28px;
}
#grid.detailed .list-row .name .desc {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.25;
}

/* Make the list column header sticky so it stays visible while scrolling the products */
.list-row.list-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #f4f3ef;  /* match the inline style */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Row details (shown on click in list) */
.row-details {
  padding: 8px 12px 12px;
  background: #f9f8f5;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  display: none;
}
.row-details.open {
  display: block;
}
.row-details .desc {
  margin-bottom: 8px;
}

/* Photo preview (hover) */
.photo-preview {
  position: fixed;
  z-index: 1000;
  max-width: 260px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 6px;
  pointer-events: none;
}
.photo-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}
.photo-preview .p-desc {
  font-size: 0.8rem;
  margin-top: 6px;
  color: var(--muted);
}

/* Simple modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28,27,25,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal.open {
  display: flex;
}
.modal-content {
  background: var(--surface);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-content img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 8px;
  background: #f4f3ef;
  margin-bottom: 12px;
}
.modal-close {
  float: right;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

@media print {
  .controls, .filters, .view-toggle,
  .photo-btn, .expand-icon {
    display: none !important;
  }

  .card {
    break-inside: avoid;
    border: 1px solid #333;
    box-shadow: none;
  }

  .list-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .list-row.list-header {
    break-after: avoid;
    page-break-after: avoid;
  }

  .row-details {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body {
    background: white;
    padding: 10px;
    color: black;
  }

  header {
    position: static;
    box-shadow: none;
  }

  /* List view table frame - ensure corners are visible */
  #grid.list-view {
    border: 1px solid #333;
    border-radius: 0;
    box-shadow: none;
  }

  .list-row {
    border-bottom: 1px solid #ccc;
    background: white;
  }

  .list-row:first-child {
    border-top: 1px solid #333;
  }

  .list-row:last-child {
    border-bottom: 1px solid #333;
  }

  .list-row.list-header {
    background: white;
    border-bottom: 2px solid #333;
    box-shadow: none;
    position: static;
  }

  .list-row .cat,
  .list-row .price,
  .list-row .detail {
    color: #333;
  }
}
