:root {
  --bg: #f4f2ec; --card: #ffffff; --ink: #1d2a2e; --muted: #5d6a6d; --line: #dcd8cd;
  --dark: #1F3A45; --green: #1F6F50; --green-2: #185c42; --wood: #c58b3e; --wood-soft: #f3e6d2;
  --r: 12px; --sh: 0 1px 2px rgba(20,30,30,.06), 0 6px 20px rgba(20,30,30,.07);
  --f-head: 'Archivo', system-ui, sans-serif; --f-body: 'Source Sans 3', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--f-body); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--f-head); font-stretch: 105%; margin: 0; line-height: 1.15; }

.ribbon { background: var(--wood-soft); color: #6d4a1a; font-size: 13px; text-align: center; padding: 5px 12px; }
body.embed .ribbon { display: none; }
.bar { height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; background: var(--dark); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand svg rect { fill: #2b5261; } .brand svg path { stroke: #E2B878; stroke-width: 3; fill: none; } .brand svg path.t { stroke-width: 4; }
.brand b { display: block; font-family: var(--f-head); font-size: 19px; letter-spacing: .01em; }
.brand small { display: block; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 8px; flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; padding: 12px 18px; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:hover { background: var(--green-2); } .btn:active { transform: translateY(1px); }
.btn.sm { padding: 8px 14px; font-size: 15px; }
.btn.ghost { background: transparent; border: 1.5px solid rgba(255,255,255,.45); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.line { background: #fff; color: var(--dark); border: 1.5px solid var(--line); }
.btn.line:hover { border-color: var(--dark); background: #fff; }
.btn.wide { width: 100%; }
.badge { background: #fff; color: var(--green); border-radius: 99px; min-width: 22px; padding: 0 6px; font-size: 13px; line-height: 20px; text-align: center; }

.app { display: grid; grid-template-columns: 250px minmax(0, 1fr) 390px; height: calc(100vh - 62px - 28px); min-height: 560px; }
body.embed .app { height: calc(100vh - 62px); }

/* catálogo */
.catalog { border-right: 1px solid var(--line); overflow-y: auto; padding: 16px 14px; background: #efece4; }
.catalog h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px 2px; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.pcard { display: block; width: 100%; text-align: left; background: var(--card); border: 2px solid transparent; border-radius: var(--r); padding: 0; cursor: pointer; overflow: hidden; box-shadow: var(--sh); transition: border-color .15s, transform .15s; }
.pcard:hover { transform: translateY(-1px); }
.pcard.on { border-color: var(--green); }
.pcard img { display: block; width: 100%; aspect-ratio: 3/2; object-fit: cover; background: #e8ebe4; }
.pcard .ph { width: 100%; aspect-ratio: 3/2; background: linear-gradient(90deg,#e8ebe4,#f1f2ee,#e8ebe4); }
.pcard div { padding: 8px 10px 10px; }
.pcard b { display: block; font-family: var(--f-head); font-size: 15.5px; }
.pcard small { color: var(--muted); font-size: 13.5px; }
.pcard.medida { background: var(--wood-soft); border: 2px dashed #d9b98a; box-shadow: none; }
.pcard.medida div { padding: 14px 12px; }

/* visor */
.stage { position: relative; min-width: 0; background: #e8ebe4; }
.viewer { position: absolute; inset: 0; }
.viewer canvas { display: block; }
.views, .modes { position: absolute; top: 12px; display: flex; background: rgba(255,255,255,.92); border-radius: 10px; padding: 3px; box-shadow: var(--sh); gap: 2px; }
.views { left: 12px; } .modes { right: 12px; }
.views button, .modes button { border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--muted); }
.views button.on, .modes button.on { background: var(--dark); color: #fff; }
.hint { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--muted); background: rgba(255,255,255,.75); padding: 3px 10px; border-radius: 99px; pointer-events: none; transition: opacity .5s; white-space: nowrap; }
.tools { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 2px; background: rgba(255,255,255,.95); padding: 5px; border-radius: 14px; box-shadow: var(--sh); max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; }
.tools button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: transparent; border-radius: 10px; padding: 6px 9px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 64px; }
.tools button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tools button:hover { background: #f0efe9; color: var(--ink); }
.tools button.on { background: #e3f0ea; color: var(--green); }
.tools button:disabled { opacity: .3; cursor: default; background: transparent; }
.subctl { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); background: rgba(255,255,255,.95); border-radius: 12px; box-shadow: var(--sh); padding: 8px 12px; display: flex; gap: 10px; align-items: center; font-size: 14.5px; white-space: nowrap; }
.subctl[hidden] { display: none; }
.subctl select, .subctl input { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; }
.subctl input[type=range] { padding: 0; }

.tag3d { background: rgba(255,255,255,.95); border: 1px solid var(--line); color: var(--ink); padding: 3px 9px; border-radius: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.tag3d.big { background: var(--dark); color: #fff; border-color: var(--dark); font-size: 14px; padding: 5px 12px; }
.tag3d.dim { background: #fff; color: var(--dark); font-family: var(--f-head); font-size: 13.5px; padding: 2px 7px; }

/* panel */
.panel { border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 20px 28px; background: var(--card); }
.panel h1 { font-size: 27px; }
.panel .sub { color: var(--muted); margin: 3px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { background: #eef3f0; color: var(--green); font-weight: 600; font-size: 13.5px; padding: 3px 10px; border-radius: 99px; }
.chip.w { background: var(--wood-soft); color: #7a531c; }
.panel p.desc { margin: 0 0 16px; }
.blk { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.blk h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 9px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 7px; }
.opt { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 8px; cursor: pointer; text-align: center; font-weight: 700; font-size: 14.5px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.opt i { display: block; width: 42px; height: 14px; border-radius: 3px; background-size: cover; }
.opt.on { border-color: var(--green); background: #f3f9f6; }
.note { font-size: 14.5px; color: var(--muted); margin: 8px 0 6px; }
.sw { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 4px 0; }
.sw input { width: 20px; height: 20px; accent-color: var(--green); margin-top: 2px; flex: none; }
.sw b { display: block; }
.sw small { color: var(--muted); font-size: 14px; }
table.spec { width: 100%; border-collapse: collapse; font-size: 15px; }
table.spec td { padding: 6px 0; border-bottom: 1px dashed #e4e0d5; vertical-align: top; }
table.spec td:last-child { text-align: right; font-weight: 700; }
.qty { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qty input { width: 100px; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; font-weight: 700; font-size: 17px; }
.qty button { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 11px; cursor: pointer; font-weight: 600; }
.qty button:hover { border-color: var(--dark); }
.logi { background: #f6f4ee; border-radius: 10px; padding: 10px 12px; margin: 10px 0 4px; font-size: 15px; }
.logi div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.logi b { text-align: right; }
.cta { display: grid; gap: 8px; margin-top: 14px; }
.cta .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sell { margin-top: 18px; background: var(--wood-soft); border-radius: 12px; padding: 14px; }
.sell b { font-family: var(--f-head); font-size: 17px; display: block; }
.sell p { margin: 4px 0 10px; font-size: 15px; color: #6b5536; }
.small { font-size: 13px; color: var(--muted); margin-top: 16px; }

/* diálogo */
dialog { border: 0; border-radius: 16px; padding: 26px 24px 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,35,.5); }
dialog h2 { font-size: 23px; margin-bottom: 6px; padding-right: 30px; }
dialog .x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 30px; line-height: 1; cursor: pointer; color: var(--muted); }
.muted { color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14.5px; }
.form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; font-weight: 400; background: #fff; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
.form .err { grid-column: 1 / -1; color: #b3261e; font-weight: 600; min-height: 1em; }
.form .btn { grid-column: 1 / -1; }
.lines { display: grid; gap: 8px; margin: 12px 0 4px; }
.line { display: flex; align-items: center; gap: 10px; background: #f6f4ee; border-radius: 10px; padding: 8px 10px; }
.line img { width: 64px; height: 43px; object-fit: cover; border-radius: 6px; background: #e8ebe4; }
.line div { flex: 1; min-width: 0; font-size: 14.5px; }
.line b { display: block; }
.line input { width: 76px; border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 6px; font-weight: 700; }
.line button { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }
.qr { display: flex; gap: 14px; align-items: center; margin: 10px 0; }
.qr img { width: 150px; height: 150px; image-rendering: pixelated; }
model-viewer { width: 100%; height: 320px; background: #eef0ea; border-radius: 12px; }
.ok { text-align: center; padding: 10px 0; }
.ok svg { width: 64px; height: 64px; stroke: var(--green); fill: none; stroke-width: 2; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; font-weight: 600; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) { .app { grid-template-columns: 210px minmax(0, 1fr) 340px; } }
@media (max-width: 900px) {
  .app { display: block; height: auto; }
  .catalog { border: 0; padding: 10px 12px; overflow-x: auto; overflow-y: hidden; }
  .catalog h2 { display: none; }
  .cards { flex-direction: row; gap: 8px; }
  .pcard { width: 136px; flex: none; }
  .pcard img, .pcard .ph { aspect-ratio: 16/10; }
  .pcard div { padding: 6px 8px 8px; }
  .pcard b { font-size: 14.5px; } .pcard small { font-size: 12.5px; line-height: 1.3; display: block; }
  .pcard.medida { width: 136px; }
  .stage { height: 56vh; min-height: 330px; }
  .panel { border: 0; padding: 18px 16px 28px; }
  .bar { padding: 0 12px; } .brand small { max-width: 160px; }
  #btnVender { display: none; }
  .tools button { min-width: 56px; padding: 5px 6px; font-size: 11.5px; }
  .views { left: 8px; top: 8px; } .modes { left: 8px; right: auto; top: 50px; } .hint { display: none; }
  .views button, .modes button { padding: 5px 9px; font-size: 13.5px; white-space: nowrap; }
  .subctl { bottom: 84px; }
  .form { grid-template-columns: 1fr; }
}

/* v3 (8-oct) · móvil */
@media (max-width: 900px) {
  /* cabecera: el lema no cabe junto al nombre (salía cortado «Catálogo 3D de palés nuev…»): en móvil y tableta se oculta */
  .brand small { display: none; }
  .brand b { line-height: 1.15; }
  /* botones de vista (3D/Arriba/Frente/Lado) y de modo (Palé/Pila/En camión) de 36 px de alto (antes 30 px) */
  .views button, .modes button { min-height: 36px; padding-block: 6px; }
  /* la fila de vistas mide ahora 42 px: la de modos baja para no tocarla */
  .modes { top: 56px; }
  /* barra de herramientas: cada botón en una línea («Con carga» y «En tu espacio» se partían); si no caben, la barra se desplaza con el dedo */
  .tools button { flex: none; white-space: nowrap; }
  .tools { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  /* el control de pila/camión pisaba 7 px la barra de herramientas; su desplegable con letra de 16 px y 36 px de alto */
  .subctl { bottom: 92px; }
  .subctl select { min-height: 36px; font-size: 16px; }
  /* la etiqueta larga del camión («Caben 33 por tráiler…») se salía por la derecha a 360 px: ahora se parte en dos líneas */
  .tag3d.big { white-space: normal; max-width: calc(100vw - 40px); text-align: center; }
  /* campos de las ventanas con letra de 16 px: así el iPhone no hace zoom al tocarlos (antes 14,5 px) */
  .form input, .form select, .form textarea, .line input { font-size: 16px; }
  /* botón de cerrar de las ventanas de 36 px (antes 27 × 32) */
  dialog .x { width: 36px; height: 36px; display: grid; place-items: center; }
}
