:root {
  --ink: #241f1c; --muted: #7b716a; --line: #e6e0da; --bg: #faf8f5; --card: #fff;
  --gold: #b48a3c; --gold-dark: #8f6b28; --accent: #3d2e3a;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; }
.muted { color: var(--muted); font-size: 13px; }
button { font: inherit; cursor: pointer; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px;
  border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.mark { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #f1e6d4;
  display: grid; place-items: center; font-family: Georgia, serif; font-size: 18px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f1ece6; color: var(--muted); }
.pill.ok { background: #e5f2e7; color: #2f6b3a; }

.layout { flex: 1; display: grid; grid-template-columns: 250px 1fr 340px; min-height: 0; }
.catalog { border-right: 1px solid var(--line); overflow: auto; background: #fff; }
.catalog-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 4px; }
.catalog h2 { font-size: 15px; margin: 0; }
#productList { list-style: none; margin: 0; padding: 6px; }
#productList li { padding: 7px 9px; border-radius: 10px; cursor: pointer; margin-bottom: 2px;
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; }
#productList .thumb { width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: #efe8df;
  display: grid; place-items: center; font: 20px Georgia, serif; color: #a08c70; }
#productList .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#productList .txt { min-width: 0; }
.list-search { margin: 4px 12px 2px; width: calc(100% - 24px); font: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; }
dialog .modes { border: 0; padding: 0; margin: 0 0 4px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
dialog .modes label { margin: 0; display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; cursor: pointer; }
dialog .modes label:has(input:checked) { border-color: var(--gold); background: #fbf6ec; }
dialog .modes input { width: auto; margin: 3px 0 0; }
dialog .modes small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.35; }
.from-image-preview { font-size: 12px; color: var(--muted); }
.from-image-preview img { max-height: 180px; max-width: 100%; border-radius: 8px; display: block; }
@media (max-width: 640px) { dialog .modes { grid-template-columns: 1fr; } }
.list-tool { margin: 6px 12px 0; width: calc(100% - 24px); }
.photo-view { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; gap: 8px; padding: 12px; background: #f4f0ea; }
.photo-view .main { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.photo-view .strip { display: flex; gap: 6px; overflow-x: auto; }
.photo-view .strip button { border: 1px solid var(--line); padding: 0; border-radius: 8px; overflow: hidden; background: #fff; flex: none; }
.photo-view .strip img { width: 64px; height: 64px; object-fit: cover; display: block; }
.small { font-size: 12px; }
.quotes { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.quotes .q { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; }
.quotes .q.chosen { border-color: var(--gold); background: #fbf6ec; }
.q-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.q-price { margin-left: auto; font-weight: 600; }
.q-acts { display: flex; gap: 10px; font-size: 12px; }
.q-acts a, .q-acts button { background: none; border: 0; padding: 0; color: #7a5a2a; cursor: pointer; text-decoration: underline; font: inherit; }
.tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: #eee6da; color: #6b5a44; }
.tag.chosen { background: var(--gold); color: #fff; } .tag.quoted { background: #e3efe5; color: #2f6b3c; }
.tag.declined { background: #f4e1df; color: #8a3a30; } .tag.best { background: #2f6b3c; color: #fff; }
.quote-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quote-form select, .quote-form input { font: inherit; font-size: 13px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.quote-form select[name=supplier], .quote-form input[name=note], .quote-form button { grid-column: 1 / -1; }
dialog.wide { width: min(640px, 94vw); max-height: 92vh; overflow: auto; }
dialog select { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; font: inherit; }
dialog .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
dialog .cols3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
dialog .check.inline { display: flex; gap: 8px; align-items: center; margin-top: 30px; }
dialog .check input { width: auto; margin: 0; flex: none; }
dialog .check:not(.inline) { display: flex; gap: 8px; align-items: center; }
.supplier-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.supplier-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.supplier-list small { display: block; color: var(--muted); }
#sourcedPreview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
#productList li:hover { background: #f6f2ee; }
#productList li.on { background: #f1e9df; }
#productList li strong { display: block; font-size: 14px; }
#productList li span { font-size: 12px; color: var(--muted); }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px;
  margin-left: 6px; background: #eee; color: #666; }
.badge.published { background: #e5f2e7; color: #2f6b3a; }
.badge.warn { background: #fbeed6; color: #8a5a00; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.viewer { flex: 1; position: relative; min-height: 300px; overflow: hidden; }
.viewer canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.loading[hidden] { display: none; }
.toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--line); background: #fff; }

.group { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.group button { border: 0; background: #fff; padding: 7px 12px; font-size: 13px; color: var(--ink); }
.group button + button { border-left: 1px solid var(--line); }
.group button.on { background: var(--accent); color: #f6eee2; }
.group.small button { padding: 5px 10px; font-size: 12px; }

.panel { border-left: 1px solid var(--line); background: #fff; padding: 18px; overflow: auto; }
.panel h1 { font-family: Georgia, serif; font-weight: normal; font-size: 26px; margin: 0 0 4px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.swatch { border: 2px solid transparent; border-radius: 10px; padding: 0; background: none; text-align: center; font-size: 10px; color: var(--muted); }
.swatch canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; display: block; }
.swatch.on { border-color: var(--gold); }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; }
.notes, .warnings { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.warnings li { color: #8a5a00; }
.files { display: flex; flex-wrap: wrap; gap: 6px; }
.files a { font-size: 12px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; }
.primary { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #f6eee2; width: 100%; margin-top: 6px; }
.primary.gold { background: var(--gold); color: #fff; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.primary.block { display: block; text-align: center; text-decoration: none; }
.ghost { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
[hidden] { display: none !important; }
a.ghost { color: inherit; text-decoration: none; font-size: 13px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin: 12px 0 8px; }
.field input { font: inherit; color: var(--ink, #241f1c); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.field input:focus-visible { outline: 2px solid #b48a3c; outline-offset: 1px; }
#unpublishBtn { width: 100%; margin-top: 8px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.gallery a img { width: 100%; border-radius: 6px; display: block; }

dialog { border: 0; border-radius: 16px; padding: 22px; width: min(460px, 92vw); }
dialog label { display: block; font-size: 13px; margin: 12px 0; }
dialog input { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; font: inherit; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }
dialog menu .primary { width: auto; margin: 0; }

body.customer .admin-only { display: none !important; }

/* embedded in a store product page (iframe): just the model and the view buttons */
body.embed { height: 100vh; background: #f3f1ee; }
body.embed .topbar, body.embed .catalog, body.embed .panel { display: none !important; }
body.embed .layout { grid-template-columns: 1fr; }
body.embed .viewer { height: auto; flex: 1; min-height: 0; }
body.embed .toolbar { justify-content: center; padding: 8px; background: rgba(255,255,255,.85); border-top: 0; }
body.embed #scenes { display: none; }
body.embed .group button { padding: 7px 11px; }
body:not(.customer) .customer-only { display: none !important; }

@media (max-width: 1000px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .catalog { border-right: 0; max-height: 220px; }
  .viewer { height: 62vh; }
}
