:root {
  --bg: #0c0e11;
  --panel: rgba(20, 24, 29, 0.82);
  --panel-solid: #15191e;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.14);
  --txt: #eef1f4;
  --muted: #9aa3ad;
  --accent: #19a7c9;
  --accent-2: #1bd0c0;
  --ok: #36c98b;
  --warn: #e7b53c;
  --err: #ef5b6b;
  --radius: 13px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); }
body { overflow: hidden; }

#app { display: flex; height: 100vh; width: 100vw; }

/* ---- escena ---- */
#stage { position: relative; flex: 1 1 auto; min-width: 0; height: 100%; }
#scene { display: block; width: 100%; height: 100%; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; z-index: 5;
}
#topbar .b1 { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: #161b20; text-shadow: 0 1px 2px rgba(255,255,255,0.45); }
#topbar .b2 { font-size: 11px; color: #3c444c; letter-spacing: 0.04em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(255,255,255,0.4); }
.hint-pill {
  pointer-events: none; background: rgba(20, 24, 29, 0.55); color: #e8edf2; backdrop-filter: blur(6px);
  font-size: 11.5px; padding: 7px 12px; border-radius: 99px; border: 1px solid rgba(255,255,255,0.12);
}

#toolbar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 6;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 99px;
  padding: 7px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.tb {
  appearance: none; border: 0; background: transparent; color: var(--txt);
  font: inherit; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 99px;
  cursor: pointer; transition: background 0.15s, color 0.15s; white-space: nowrap;
}
.tb:hover { background: rgba(255, 255, 255, 0.08); }
.tb.active { background: var(--accent); color: #04222a; }

/* ---- panel ---- */
#panel {
  width: 392px; flex: 0 0 392px; height: 100%; overflow-y: auto;
  background: var(--panel-solid); border-left: 1px solid var(--line);
  padding: 0 20px 28px; scrollbar-width: thin; scrollbar-color: #2c333b transparent;
}
#panel::-webkit-scrollbar { width: 9px; }
#panel::-webkit-scrollbar-thumb { background: #2c333b; border-radius: 9px; }

.cfg-brand { position: sticky; top: 0; z-index: 2; background: var(--panel-solid);
  padding: 18px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.cfg-logo { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.cfg-logo::after { content: ""; }
.cfg-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.cfg-ref { margin: 14px 0; }
.cfg-ref label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; }
.cfg-ref input { width: 100%; }

.cfg-step { padding: 16px 0; border-top: 1px solid var(--line); }
.cfg-h { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 700;
  margin: 0 0 12px; letter-spacing: -0.01em; }
.cfg-num { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04222a;
  font-size: 11px; font-weight: 800; }

.hint { font-size: 11.5px; color: var(--muted); margin: -2px 0 12px; line-height: 1.5; }
.muted { color: var(--muted); }

/* swatches */
.swatch-grid { display: grid; gap: 8px; }
.swatch-grid.cols-1 { grid-template-columns: 1fr; }
.swatch-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.swatch {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 9px 11px; font: inherit; transition: border-color 0.15s, background 0.15s;
}
.swatch:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.06); }
.swatch.is-active { border-color: var(--accent); background: rgba(25, 167, 201, 0.12); box-shadow: 0 0 0 1px var(--accent) inset; }
.swatch-chip { width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.18); }
.swatch-label { font-size: 12.5px; font-weight: 600; line-height: 1.2; display: flex; flex-direction: column; }
.swatch-label small { font-weight: 500; font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* medidas */
.size-row { margin-bottom: 16px; }
.size-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; }
.size-head .muted, #w-range, #h-range { font-size: 11px; font-weight: 500; }
.slider-line { display: flex; align-items: center; gap: 11px; }
.slider-line input[type="range"] { flex: 1; }
.num { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.num input { width: 56px; background: transparent; border: 0; color: var(--txt); font: inherit; font-size: 13px; font-weight: 600; text-align: right; }
.num span { font-size: 10.5px; color: var(--muted); }
.leaf-note { font-size: 11px; margin-top: 7px; }

/* medidores */
.meters { display: grid; gap: 11px; margin-top: 6px; }
.meter-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.bar { height: 7px; background: rgba(255,255,255,0.07); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: var(--ok); border-radius: 99px; transition: width 0.25s, background 0.25s; }
.bar i.warn { background: var(--warn); }
.bar i.over { background: var(--err); }

/* inputs genéricos */
input[type="text"], input[type="number"], select {
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 13px; width: 100%;
  color-scheme: dark; /* lista desplegable nativa en oscuro (evita blanco sobre blanco) */
}
select option { background-color: #1b1f24; color: #eef1f4; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3ad' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 28px; }

.field { display: block; margin-bottom: 11px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 500; margin: 9px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.jp-box { max-height: 0; overflow: hidden; opacity: 0.3; transition: max-height 0.25s, opacity 0.25s; }
.jp-box.open { max-height: 420px; opacity: 1; margin-top: 6px; padding: 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 10px; }

/* range slider */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 99px;
  background: rgba(255,255,255,0.13); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid #06262e; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #06262e; }

/* validación */
.validation { margin: 12px 0; padding: 12px 14px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.validation.ok { background: rgba(54,201,139,0.1); border-color: rgba(54,201,139,0.35); color: #aef0cf; }
.validation.warn { background: rgba(231,181,60,0.1); border-color: rgba(231,181,60,0.4); color: #f4dca0; }
.validation.err { background: rgba(239,91,107,0.1); border-color: rgba(239,91,107,0.45); color: #ffc3cb; }
.v-title { font-weight: 700; margin-bottom: 4px; }
.validation ul { margin: 4px 0 0; padding-left: 16px; line-height: 1.55; }

/* resumen */
.summary { display: grid; gap: 0; margin-bottom: 12px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.sum-row span { color: var(--muted); }
.sum-row b { font-weight: 600; text-align: right; }

.cutlist { margin-bottom: 14px; }
.cut-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.cutlist table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.cutlist th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line-2); font-size: 10.5px; }
.cutlist td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.cutlist td:nth-child(3), .cutlist td:nth-child(4), .cutlist th:nth-child(3), .cutlist th:nth-child(4) { text-align: right; }

/* precio */
.price-card { background: linear-gradient(135deg, rgba(25,167,201,0.13), rgba(27,208,192,0.07));
  border: 1px solid rgba(25,167,201,0.32); border-radius: 12px; padding: 14px 15px; margin-bottom: 12px; }
.price-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--muted); }
.price-row b { color: var(--txt); font-weight: 600; }
.price-row.total { border-top: 1px solid var(--line-2); margin-top: 5px; padding-top: 9px; font-size: 17px; }
.price-row.total b { font-size: 19px; font-weight: 800; }
.pvp { font-size: 10px; color: var(--warn); margin-top: 8px; letter-spacing: 0.02em; }

/* botones */
.btn { appearance: none; border: 1px solid var(--line-2); background: rgba(255,255,255,0.05); color: var(--txt);
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 11px 14px; border-radius: 10px; cursor: pointer; transition: 0.15s; }
.btn:hover { background: rgba(255,255,255,0.1); }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #04222a; }
.btn-accent:hover { filter: brightness(1.08); }
.w-full { width: 100%; display: block; text-align: center; text-decoration: none; margin-top: 10px; }
.pdf-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* dealer */
.dealer-card { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; margin-top: 10px; }
.dealer-name { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.dealer-card .muted { font-size: 11.5px; line-height: 1.5; }

.foot { font-size: 10px; line-height: 1.5; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* loading */
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; transition: opacity 0.5s; }
#loading.hide { opacity: 0; pointer-events: none; }
.spin { width: 38px; height: 38px; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
.load-txt { margin-top: 14px; font-size: 13px; color: var(--muted); }
.err-load { color: #ffc3cb; text-align: center; font-size: 14px; line-height: 1.6; max-width: 420px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 920px) {
  #app { flex-direction: column; }
  #stage { flex: 0 0 50vh; height: 50vh; }
  #panel { width: 100%; flex: 1 1 auto; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  #toolbar { bottom: 12px; }
  .cfg-brand { position: static; }
  .hint-pill { display: none; }
}
