/* Showroom Visualizer — warm neutral showroom palette, deep teal accent. No web fonts (works offline). */
:root {
  --bg: #f4f1ec;
  --panel: #fbfaf7;
  --card: #ffffff;
  --ink: #1f1d1a;
  --ink-2: #5d5850;
  --ink-3: #8c867c;
  --line: #e3ded5;
  --accent: #0f5c5c;
  --accent-2: #e3efed;
  --warn: #a8461f;
  --ok: #2f6b3a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 29, 26, .06), 0 4px 16px rgba(31, 29, 26, .05);
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; letter-spacing: -.01em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; }
h3 small { text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; }
p { margin: .4em 0; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.boot, p.empty { padding: 40px; color: var(--ink-2); text-align: center; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; font-weight: 500; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--warn); }
.btn.wide { width: 100%; }
.btn.on { background: var(--accent-2); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .6; cursor: wait; }
input:not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]), select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-error { color: var(--warn); min-height: 1.2em; font-size: 14px; }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--accent-2); color: var(--accent); }

/* brand mark: 2x2 tiles */
.mark { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 22px; height: 22px; }
.mark span:nth-child(1), .mark span:nth-child(4) { background: var(--accent); }
.mark span:nth-child(2), .mark span:nth-child(3) { background: #b9a88f; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; gap: 28px; padding: 32px 16px; align-content: center; }
.login-brand { text-align: center; }
.login-brand .mark { width: 44px; height: 44px; gap: 4px; margin: 0 auto 14px; }
.login-brand h1 { font-size: 30px; margin: 0; }
.login-brand p { color: var(--ink-2); }
.login-cards { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.login-card { background: var(--card); padding: 26px; border-radius: 14px; box-shadow: var(--shadow); width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 10px; }
.login-card h2 { font-size: 20px; margin: 0; }
.login-card.admin { background: var(--panel); }
.code-input { font-size: 28px !important; letter-spacing: .18em; text-align: center; font-family: ui-monospace, Consolas, monospace !important; text-transform: uppercase; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.spacer { flex: 1; }
.nav { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav.on { color: var(--accent); background: var(--accent-2); }

/* viewer */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 53px); }
.left { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bars { display: flex; align-items: center; gap: 8px 12px; padding: 10px 14px; flex: none; flex-wrap: wrap; }
.room-bar { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 100%; min-width: 0; padding-bottom: 2px; }   /* rooms on their own row */
.option-bar { display: flex; gap: 6px; align-items: center; flex: none; }
.bars-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.view-bar:empty { display: none; }
.room-chip.add { padding: 4px 12px; color: var(--accent); border-style: dashed; font-weight: 600; }
.surface.hidden-view { opacity: .72; }
.surface.sub { margin-left: 22px; padding: 4px 6px; }
.surface.sub .sw { width: 26px; height: 26px; }
.surface .sw.glass { background: linear-gradient(135deg, #dfeef2 0%, #f6fbfc 45%, #cfe3e8 46%, #eef6f8 100%); border-color: #b9cfd4; }
.surface.hidden-view .sw { filter: grayscale(.4); }
.room-chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; white-space: nowrap; }
.room-chip img { width: 46px; height: 30px; object-fit: cover; border-radius: 5px; }
.room-chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 14px 14px; }
.stage.loading { opacity: .5; }
.canvas-wrap { position: relative; max-width: 100%; max-height: 100%; display: flex; }
.room-canvas { max-width: 100%; max-height: calc(100vh - 53px - 70px); width: auto; height: auto; border-radius: 6px;
  box-shadow: var(--shadow); background: #ddd; display: block; }
.compare-layer { position: absolute; inset: 0; display: none; cursor: ew-resize; touch-action: none; border-radius: 6px; overflow: hidden; }
.compare-layer.on { display: block; }
.compare-layer img { display: block; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.compare-layer .under { width: 100%; }
.compare-layer .clip { position: absolute; inset: 0 auto 0 0; overflow: hidden; }
.compare-layer .clip img { max-width: none; }
.compare-layer .divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.4); transform: translateX(-1px); }
.compare-layer .divider span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: var(--ink);
  border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; box-shadow: var(--shadow); font-size: 16px; }
.compare-layer .tag { position: absolute; top: 12px; background: rgba(20,20,18,.72); color: #fff; padding: 3px 10px; border-radius: 6px; font-weight: 600; }
.compare-layer .tag.left { left: 12px; }
.compare-layer .tag.right { right: 12px; }
.compare-layer .close { position: absolute; bottom: 12px; right: 12px; }
.stage-hint { position: absolute; left: 12px; top: 12px; background: rgba(20,20,18,.72); color: #fff; padding: 4px 10px;
  border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 4px 16px 24px; }
.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.surface-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.surface { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left;
  padding: 6px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.surface:hover { background: rgba(0,0,0,.03); }
.surface.on { background: var(--card); border-color: var(--accent); }
.surface .sw { grid-row: span 2; width: 34px; height: 34px; border-radius: 6px; background-size: cover; background-position: center; border: 1px solid var(--line); }
.surface .sw.empty { background: repeating-linear-gradient(45deg, #eee, #eee 4px, #f8f8f8 4px, #f8f8f8 8px); }
.surface:not(:has(.sw)) { grid-template-columns: 1fr; }
.sname { font-weight: 600; font-size: 14px; }
.stile { font-size: 12px; color: var(--ink-3); }
.search { flex: 1; min-width: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; max-height: 420px; overflow-y: auto; padding: 2px; }
.tile-card { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 6px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; }
.tile-card:hover { border-color: var(--ink-3); }
.tile-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb { aspect-ratio: 4 / 3; border-radius: 6px; background-size: cover; background-position: center; margin-bottom: 4px; }
.thumb.contain { background-size: contain; background-repeat: no-repeat; background-color: #f1efea; background-origin: content-box; padding: 6px; }
.surface .sw.cut { background-size: contain; background-repeat: no-repeat; background-color: #f1efea; }
.row.tight { margin-top: 10px; }
.tname { font-weight: 600; font-size: 13px; line-height: 1.25; }
.tmeta { font-size: 12px; color: var(--ink-3); text-transform: capitalize; }
.tfoot { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-top: 2px; }
.tfoot small { color: var(--ink-3); font-weight: 400; }
.stock { color: var(--ok); }
.stock.out { color: var(--warn); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.seg button { padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg.small { margin: 0; }
.field { flex: 1; }
.swatches { display: flex; gap: 6px; align-items: center; margin: 10px 0; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches input[type=color] { width: 30px; height: 30px; border: 0; padding: 0; background: none; }
table.qty { width: 100%; border-collapse: collapse; font-size: 13px; }
table.qty td { padding: 6px 4px; border-bottom: 1px dashed var(--line); vertical-align: top; }
table.qty small { display: block; color: var(--ink-3); font-weight: 400; }
.num { text-align: right; white-space: nowrap; }
.warn { color: var(--warn); }
.total { text-align: right; margin-top: 8px; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .row .btn { flex: 1; }

dialog.modal { border: 0; border-radius: 14px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); min-width: 320px; max-width: 92vw; }
dialog.modal.wide { width: min(1200px, 94vw); }
dialog::backdrop { background: rgba(20, 18, 15, .45); }
img.export { width: 100%; border-radius: 8px; display: block; margin-bottom: 12px; }
.design-list { list-style: none; padding: 0; margin: 0 0 12px; }
.design-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); transition: opacity .4s; }
.toast.error { background: var(--warn); }
.toast.out { opacity: 0; }

/* admin */
.admin { max-width: 1280px; margin: 0 auto; padding: 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.card.inner { box-shadow: none; border: 1px solid var(--line); background: var(--panel); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-grid.cols4 { grid-template-columns: repeat(4, 1fr); }
.code-result { border: 1px dashed var(--accent); border-radius: 10px; padding: 14px; text-align: center; background: var(--accent-2); }
.big-code { font: 600 34px ui-monospace, Consolas, monospace; letter-spacing: .14em; color: var(--accent); margin: 6px 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--ink-3); font-weight: 500; padding: 6px; border-bottom: 1px solid var(--line); }
table.data td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.data tbody tr:hover { background: var(--panel); cursor: default; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eee; }
.status.active { background: #e2f0e4; color: var(--ok); }
.status.unused { background: var(--accent-2); color: var(--accent); }
.status.revoked, .status.expired { background: #f6e6df; color: var(--warn); }
.mini-sw { display: inline-block; width: 22px; height: 22px; border-radius: 4px; background-size: cover; }
.steps { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.photo-stage { position: relative; line-height: 0; cursor: crosshair; }
.photo-stage img { width: 100%; height: auto; border-radius: 6px; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.overlay circle { fill: #fff; stroke: var(--accent); stroke-width: 3; }
.overlay text { fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 4; font-weight: 700; }
.overlay polygon, .overlay polyline { fill: rgba(15, 92, 92, .12); stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.overlay g:not(.on) { opacity: .45; }
.overlay .outline { fill: rgba(255, 170, 60, .18); stroke: #e08a1e; stroke-dasharray: 8 6; }
.overlay .hole { fill: rgba(200, 40, 40, .2); stroke: #c0392b; stroke-dasharray: 6 5; }
.overlay .handle { cursor: grab; }
.overlay .slot .slotbox { fill: rgba(40, 120, 230, .16); stroke: #2878e6; stroke-dasharray: 5 4; }
.overlay .slot .base { stroke: #2878e6; }
.overlay g.slot:not(.on) { opacity: .6; }
img.checker, .checkwrap { background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.checkwrap { display: block; border-radius: 6px; border: 1px solid var(--line); }
.cutout-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cutout-item { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.cutout-item .thumb { display: block; aspect-ratio: 1; margin: 8px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.texture-result { display: flex; gap: 14px; align-items: center; }
.texture-result img { width: 140px; border-radius: 6px; border: 1px solid var(--line); }
.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-item { display: flex; gap: 12px; align-items: center; }
.room-item img { width: 140px; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px; }
.room-thumbs { display: flex; gap: 4px; flex: none; }
.room-thumbs img { width: 96px; }
.room-item { flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.setup-side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 70px; }
.help { background: #fff7e6; border: 1px solid #f1d9a6; padding: 10px 12px; border-radius: 8px; font-size: 13px; }

/* brand catalogues */
.cat-filters select { width: auto !important; }
.cat-filters .search { flex: 1; min-width: 200px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 6px; }
.cat-card { display: flex; flex-direction: column; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); position: relative; cursor: pointer; }
.cat-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cat-card input[type=checkbox] { position: absolute; top: 12px; left: 12px; width: 18px; height: 18px; z-index: 1; }
.cat-card b { font-size: 13px; line-height: 1.25; }
.cat-thumb { aspect-ratio: 1; display: grid; place-items: center; background: #f6f5f2; border-radius: 6px; overflow: hidden; margin-bottom: 4px; }
.cat-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cat-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-top: auto; }
.status.in_stock { background: #e2f0e4; color: var(--ok); }
.status.needs_photo, .status.needs_size { background: #fbefd8; color: #8a5a00; }
.status.skipped { background: #eee; color: var(--ink-3); }
.cat-job { display: flex; flex-direction: column; gap: 6px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
pre.tiny { white-space: pre-wrap; font-size: 11px; max-height: 160px; overflow: auto; }

.status.check { background: #fbefd8; color: #8a5a00; }
.fix-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin: 10px 0; align-items: start; }
.fix-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.fix-photo { width: 100%; border-radius: 6px; cursor: crosshair; border: 1px solid var(--line); }
.fix-photo:hover { outline: 2px solid var(--accent); }
.fix-preview { width: 100%; max-height: 340px; object-fit: contain; border-radius: 6px; display: block; margin-top: 6px; }

/* quote */
dialog.quote { width: min(900px, 96vw); }
.quote-sheet { color: var(--ink); }
.q-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding: 14px 0 10px; margin-top: 10px; }
.q-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; }
.q-customer { margin: 12px 0 4px; border: 0 !important; border-bottom: 1px dashed var(--line) !important; border-radius: 0 !important; font-size: 16px; padding-left: 0 !important; }
.q-option { margin-top: 18px; break-inside: avoid; }
.q-option h2 { font-size: 17px; margin-bottom: 8px; }
.q-img { width: 100%; border-radius: 6px; display: block; margin-bottom: 10px; }
.q-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.q-table th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--ink); padding: 5px 4px; }
.q-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.q-table td small { display: block; color: var(--ink-3); }
.q-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.q-notes { font-size: 11px; color: var(--ink-2); margin-top: 16px; }
.print-root { display: none; }
.q-customer-print { font-size: 16px; margin: 12px 0 4px; }
.q-customer-print:empty { display: none; }
@media print {
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block; }
  html, body { background: #fff !important; }
  .q-option + .q-option { break-before: page; }
  @page { margin: 12mm; }
}

@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; height: auto; }
  .room-canvas { max-height: 38vh; }
  /* keep the room in view while scrolling the tile list */
  .topbar { position: static; padding: 8px 12px; gap: 8px; }
  .brand, .badge, .topbar .btn { white-space: nowrap; }
  .left { position: sticky; top: 0; z-index: 4; background: var(--bg); box-shadow: 0 8px 12px -10px rgba(0,0,0,.35); }
  .bars { padding: 8px 10px; gap: 8px; }
  .stage { padding: 0 10px 10px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .admin-grid, .setup-grid { grid-template-columns: 1fr; }
  .form-grid.cols4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .topbar .brand { font-size: 0; gap: 0; }   /* logo mark only, so the buttons fit */
  .nav { padding: 6px 8px; }
}
