:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --panel: #ffffff;
  --text: #20211f;
  --muted: #666b61;
  --line: #d9ddd2;
  --accent: #176b5b;
  --danger: #9b2d20;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 12px max(5vw, calc((100% - 1400px) / 2));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 4px;
}

.topbar nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
}

a {
  color: var(--accent);
}

.shell {
  width: min(1400px, 90vw);
  margin: 0 auto;
  padding: 32px 0;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.link-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.button.secondary {
  background: #fff;
  color: var(--accent);
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

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

.narrow {
  max-width: 460px;
}

.form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 400;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

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

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.table-wrap.flat {
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f2ed;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
  min-width: 340px;
}

.actions-cell {
  text-align: right;
  white-space: normal;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.compact-panel {
  margin-bottom: 18px;
}

.compact-panel h2,
.product-group h2 {
  margin: 0;
}

.product-group {
  margin-bottom: 18px;
}

.group-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  list-style: none;
}

.group-summary::-webkit-details-marker {
  display: none;
}

.group-summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 1.1rem;
}

.product-group[open] .group-summary::before {
  content: '▾';
}

.group-toggle {
  margin-left: auto;
  color: var(--accent);
  font-size: 0.95rem;
}

.group-count {
  color: var(--muted);
}

.group-body {
  margin-top: 16px;
}

.group-toolbar {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.drag-handle {
  width: 42px;
  color: var(--muted);
  cursor: grab;
  text-align: center;
  user-select: none;
}

tr.dragging {
  opacity: 0.45;
}

.thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.image-preview {
  width: 160px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.logo-preview {
  width: 180px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.field-caption,
.volume-output {
  margin: 0;
}

.sub-panel,
.options-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.sub-panel h2 {
  margin: 0 0 8px;
}

.option-link-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.buy-links {
  display: grid;
  gap: 10px;
}

.buy-link-row {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.buy-link-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.buy-link-row input {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.generated-url {
  overflow-wrap: anywhere;
}

.option-link-row:first-of-type {
  border-top: 0;
}

.options-box {
  display: grid;
  gap: 8px;
  margin: 20px 0 0;
  max-width: 100%;
}

.options-box legend {
  font-weight: 700;
  padding: 0 6px;
}

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

.product-cart-form {
  display: grid;
  gap: 0;
  align-items: start;
}

.option-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.option-choice:first-of-type {
  border-top: 0;
}

.option-choice-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.option-choice-name {
  overflow-wrap: anywhere;
}

.option-choice-price {
  white-space: nowrap;
}

.qty-input {
  width: 82px;
}

.cart-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(20, 24, 21, 0.52);
  backdrop-filter: blur(5px);
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  padding: 22px;
}

.modal h2 {
  margin: 0 0 10px;
}

.modal p {
  margin: 0 0 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.modal-open {
  overflow: hidden;
}

.error,
.toast {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

.error {
  border-color: #e2b2aa;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: max(20px, 5vw);
  bottom: 24px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 40px));
  box-shadow: 0 12px 30px rgba(20, 24, 21, 0.18);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.product-detail {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.product-detail.no-media {
  grid-template-columns: minmax(0, 1fr);
  max-width: 980px;
}

.product-detail img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.lead {
  font-size: 1.1rem;
}

.price {
  margin: 20px 0 0;
  font-size: 1.7rem;
  font-weight: 700;
}

.product-facts {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.product-facts div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
}

.product-facts dt {
  color: var(--muted);
}

.product-facts dd {
  margin: 0;
}

.cart-line {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 20px;
}

.cart-line label {
  max-width: 120px;
}

.checkout-summary {
  display: grid;
  gap: 14px;
}

.summary-line,
.summary-totals div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.summary-totals div:last-child {
  border-bottom: 0;
  font-size: 1.1rem;
}

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

  .topbar nav {
    justify-content: flex-start;
  }

  .brand {
    max-width: 100%;
  }

  .group-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }

  .group-toggle {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
  }

  .grid-two,
  .grid-three,
  .page-head,
  .product-detail {
    grid-template-columns: 1fr;
    display: grid;
  }

  .group-head,
  .inline-form,
  .option-link-row,
  .buy-link-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .cart-actions {
    display: grid;
  }

  .inline {
    justify-content: stretch;
    width: 100%;
  }

  .actions {
    min-width: 0;
    justify-content: stretch;
  }

  .actions > *,
  .actions button,
  .actions .button,
  .inline button {
    width: 100%;
  }

  th:last-child,
  .actions-cell {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 142px;
    background: #fff;
    box-shadow: -1px 0 0 var(--line);
  }

  th:last-child {
    background: #f0f2ed;
  }

  .cart-line {
    align-items: stretch;
    flex-direction: column;
  }
}
