/* Configurador 3D Outline Plus · Palbox — estilos */
:root {
  --teal: #75c5c1; --teal-d: #4aa39e; --teal-bg: #e7f5f4;
  --ink: #1e2426; --ink-2: #3b4346; --grey: #6f7679; --line: #e3e6e5; --bg: #f4f5f4; --card: #ffffff;
  --bad: #d9453b; --bad-bg: #fdecea; --warn: #d98b1e; --warn-bg: #fff4e3; --ok: #2f9d6c; --ok-bg: #e6f6ee;
  --radius: 12px; --shadow: 0 6px 24px rgba(20, 30, 32, .10);
  --ico-wall: #dfe3e2; --ico-open: #f7fbfb; --ico-door: #bfe6e3; --ico-fixed: #eef1f0; --ico-line: #2f393c; --ico-accent: #2a8b86;
  --panel-w: 430px; --top-h: 64px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); overflow: hidden; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }
b { font-weight: 600; }
.muted { color: var(--grey); }
.teal { color: var(--teal-d); }
[hidden] { display: none !important; }

/* ---------- Carga ---------- */
#loading { position: fixed; inset: 0; z-index: 50; background: var(--ink); color: #fff; display: grid; place-content: center; text-align: center; gap: 14px; transition: opacity .5s; }
#loading.hide { opacity: 0; pointer-events: none; }
#loading .spinner { width: 46px; height: 46px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--teal); border-radius: 50%; margin: 0 auto; animation: spin 1s linear infinite; }
#loading .err { background: #fff; color: var(--ink); padding: 20px 26px; border-radius: 12px; line-height: 1.6; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cabecera ---------- */
.topbar { height: var(--top-h); background: var(--ink); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 2px solid var(--teal); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { height: 38px; width: auto; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 15px; letter-spacing: .2px; }
.brand-txt span { font-size: 11.5px; color: #b8c2c4; white-space: nowrap; }
.topbar-mid { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; margin-right: 8px; }
.status svg { width: 16px; height: 16px; }
.status.ok { background: rgba(47,157,108,.2); color: #8fe3b7; }
.status.warn { background: rgba(217,139,30,.22); color: #ffd28a; }
.status.bad { background: rgba(217,69,59,.25); color: #ffb3ad; }
.price-box { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; margin-right: 6px; }
.price-box b { font-size: 20px; color: var(--teal); letter-spacing: -.3px; }
.price-box span { font-size: 10.5px; color: #b8c2c4; }
.btn { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn.primary { background: var(--teal); color: var(--ink); }
.btn.primary:hover { background: #8dd3cf; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.22); }
.btn.ghost:hover { border-color: var(--teal); color: var(--teal); }
.modal .btn.ghost { color: var(--ink); border-color: var(--line); }
.modal .btn.ghost:hover { border-color: var(--teal-d); color: var(--teal-d); }
.btn.small { padding: 6px 10px; font-size: 12px; background: var(--teal-bg); color: var(--teal-d); }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: 9px; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #cfd6d7; display: grid; place-items: center; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.badge { position: absolute; top: -6px; right: -6px; background: var(--teal); color: var(--ink); font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }
.only-mobile { display: none; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 1fr var(--panel-w); height: calc(100% - var(--top-h)); }
.viewer { position: relative; overflow: hidden; background: #e9ebea; }
#scene { position: absolute; inset: 0; }
#scene canvas { display: block; width: 100% !important; height: 100% !important; }
.overlay { position: absolute; z-index: 5; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.top-left { top: 16px; left: 16px; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.top-right { top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.bottom { bottom: 16px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chip-info { background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; box-shadow: var(--shadow); }
.hint { margin: 0; font-size: 11px; color: var(--grey); background: rgba(255,255,255,.7); padding: 3px 10px; border-radius: 999px; }
.toolbar { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: transparent; border-radius: 10px; padding: 6px 10px; color: var(--ink-2); font-size: 10.5px; min-width: 58px; }
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: var(--bg); }
.tool.active { background: var(--teal-bg); color: var(--teal-d); }
.toolbar .sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.open-slider { display: flex; align-items: center; padding: 0 6px; }
.open-slider input { width: 110px; accent-color: var(--teal-d); }
.seg { display: inline-flex; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.active { background: var(--ink); color: #fff; }
.seg.envs button.active { background: var(--teal); color: var(--ink); }
.dim-label { font-size: 11px; font-weight: 600; color: var(--ink); background: rgba(255,255,255,.92); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); white-space: nowrap; }
.dim-label.main { font-size: 12px; border-color: var(--teal); }
.dim-label.panel { color: var(--teal-d); }

/* ---------- Incidencias ---------- */
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.35; background: var(--card); box-shadow: var(--shadow); border-left: 4px solid var(--line); flex-wrap: wrap; }
.issue svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.issue span { flex: 1 1 200px; }
.issue.error { border-left-color: var(--bad); background: var(--bad-bg); color: #7a1f18; }
.issue.warn { border-left-color: var(--warn); background: var(--warn-bg); color: #6c4407; }
.issue.info { border-left-color: var(--teal); background: var(--teal-bg); color: #24504e; }
.issue.ok { border-left-color: var(--ok); background: var(--ok-bg); color: #1d5d40; }
.issue .fix { margin-left: auto; border: 0; background: var(--ink); color: #fff; border-radius: 7px; padding: 5px 10px; font-size: 11.5px; font-weight: 600; }
.issue .fix:hover { background: var(--teal-d); }

/* ---------- Panel ---------- */
.panel { background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 40px; }
.step { border-bottom: 1px solid var(--line); }
.step header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--card); z-index: 2; }
.step header .n { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 700; font-size: 12.5px; display: grid; place-items: center; }
.step header h3 { margin: 0; font-size: 14px; }
.step header p { margin: 1px 0 0; font-size: 11.5px; color: var(--grey); }
.step header .chev { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--grey); border-bottom: 2px solid var(--grey); transform: rotate(45deg); transition: .2s; }
.step.collapsed .chev { transform: rotate(-45deg); }
.step .body { padding: 4px 18px 18px; }
.step.collapsed .body { display: none; }
.step.disabled .body { opacity: .4; pointer-events: none; }
.disabled { opacity: .4; pointer-events: none; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--grey); font-weight: 700; margin: 12px 0 8px; display: flex; align-items: center; gap: 8px; }
.demo-tag { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 2px 6px; font-size: 10px; letter-spacing: 0; text-transform: none; }

.sys-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sys-card { border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); padding: 8px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; transition: .15s; }
.sys-card:hover { border-color: #bcd; }
.sys-card.active { border-color: var(--teal-d); background: var(--teal-bg); box-shadow: 0 0 0 3px rgba(117,197,193,.25); }
.sys-ico { width: 100%; height: auto; border-radius: 6px; }
.sys-name { font-size: 11.5px; font-weight: 600; line-height: 1.2; }
.sys-sub { font-size: 10px; color: var(--grey); }
.sys-desc { font-size: 12.5px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 9px 12px; margin: 10px 0 0; }

.measure-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.measure { display: flex; flex-direction: column; gap: 5px; }
.measure > span { font-size: 12px; font-weight: 600; }
.measure .num { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 9px; padding: 0 10px 0 0; overflow: hidden; }
.measure .num input { border: 0; width: 100%; padding: 9px 10px; font-size: 16px; font-weight: 600; outline: none; background: transparent; }
.measure .num em { font-style: normal; color: var(--grey); font-size: 12px; }
.measure .num:focus-within { border-color: var(--teal-d); }
.measure input[type=range] { accent-color: var(--teal-d); width: 100%; }
.measure small { font-size: 11px; color: var(--grey); }
.measure small.bad { color: var(--bad); font-weight: 600; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 10px; font-size: 11.5px; }
.chip:hover { border-color: var(--teal-d); color: var(--teal-d); }
.computed { margin-top: 10px; background: var(--teal-bg); color: #24504e; border-radius: 9px; padding: 9px 12px; font-size: 12.5px; }

.opt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; }
.opt b { font-size: 12.5px; }
.opt span { font-size: 11px; color: var(--grey); }
.opt.active { border-color: var(--teal-d); background: var(--teal-bg); }
#closerRow { grid-template-columns: 1fr 1fr 1fr; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.swatch i { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); box-shadow: inset 0 -6px 10px rgba(0,0,0,.12), inset 0 4px 6px rgba(255,255,255,.35); }
.swatch.glass i { border-radius: 8px; width: 40px; height: 30px; background-image: linear-gradient(135deg, rgba(255,255,255,.7), transparent 40%, rgba(0,0,0,.05)); }
.swatch b { font-size: 11.5px; }
.swatch span { font-size: 10px; color: var(--grey); line-height: 1.2; }
.swatch.active { border-color: var(--teal-d); background: var(--teal-bg); }
.ral-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; }
.ral-row input[type=color] { width: 40px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: none; }
.ral-row input[type=text] { width: 90px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.panel .seg { box-shadow: none; background: var(--bg); }
.panel .seg button.active { background: var(--ink); color: #fff; }

.div-row { display: flex; gap: 14px; align-items: center; margin-top: 6px; }
.div-prev { width: 64px; flex: 0 0 auto; }
.div-ico { width: 100%; height: auto; }
.steppers { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.stepper { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.stepper > div { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--bg); width: 30px; height: 28px; font-size: 16px; }
.stepper b { width: 34px; text-align: center; }
.handles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.handle { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.handle-ico { width: 30px; height: auto; }
.handle b { font-size: 10.5px; line-height: 1.15; }
.handle span { font-size: 9px; color: var(--grey); line-height: 1.15; }
.handle.active { border-color: var(--teal-d); background: var(--teal-bg); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; background: var(--bg); padding: 7px 9px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--grey); }
.tbl td { padding: 7px 9px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl td small { display: block; color: var(--grey); font-size: 10.5px; }
.tbl tr.bad td { background: var(--bad-bg); color: #7a1f18; }
#tblPrice td:nth-child(n+2), #tblPrice th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.weight { display: flex; flex-direction: column; gap: 5px; margin: 10px 0 4px; font-size: 12px; color: var(--ink-2); }
.weight .bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.weight .bar i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.weight .bar i.warn { background: var(--warn); } .weight .bar i.over { background: var(--bad); }
.totals { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { border-top: 2px solid var(--ink); padding-top: 6px; margin-top: 4px; font-size: 17px; }
.totals .grand b { color: var(--teal-d); }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12.5px; font-weight: 600; }
.legal { font-size: 10.5px; color: var(--grey); line-height: 1.4; margin: 12px 0 0; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,26,28,.55); backdrop-filter: blur(3px); z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--card); border-radius: 16px; width: min(720px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 17px; }
.modal .x { border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 8px; font-size: 20px; line-height: 1; }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--bg); }
.order-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.order-summary div { display: flex; flex-direction: column; }
.order-summary small { font-size: 10.5px; color: var(--grey); text-transform: uppercase; letter-spacing: .4px; }
.order-summary b { font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--grey); }
.form-grid input:not([type=checkbox]), .form-grid textarea { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; font-weight: 400; }
.form-grid input:focus, .form-grid textarea:focus { outline: none; border-color: var(--teal-d); }
.confirm { text-align: center; padding: 10px 0; }
.big-ok { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 34px; display: grid; place-items: center; margin: 0 auto 10px; }
.confirm h3 { margin: 4px 0; }
.confirm p { margin: 6px 0; }
.orders { display: flex; flex-direction: column; gap: 8px; }
.order-row { display: grid; grid-template-columns: 1.2fr 1.4fr auto auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.order-row small { display: block; color: var(--grey); font-size: 11px; }
.modal.cad { width: min(1100px, 100%); height: 88vh; }
.cad-body { display: grid; grid-template-columns: 1fr 280px; flex: 1; min-height: 0; }
.cad-view { position: relative; min-height: 0; }
.cad-view canvas { display: block; width: 100% !important; height: 100% !important; }
.cad-body aside { padding: 18px; border-left: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; overflow-y: auto; }
.cad-body aside p { margin: 0 0 12px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: .3s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.err { color: var(--bad); padding: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) { :root { --panel-w: 380px; } .brand-txt span { display: none; } #btnPdfNo { display: none; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .panel { position: fixed; top: var(--top-h); right: 0; bottom: 0; width: min(430px, 100%); transform: translateX(100%); transition: .25s; z-index: 20; box-shadow: var(--shadow); }
  body.panel-open .panel { transform: none; }
  .only-mobile { display: grid; }
  .topbar { gap: 8px; padding: 0 10px; }
  .btn.ghost, .price-box span, .topbar-mid .icon-btn:not(#btnOrders) { display: none; }
  .toolbar .tool span { display: none; } .tool { min-width: 40px; }
  .open-slider input { width: 70px; }
  .top-left { max-width: 70vw; }
  .top-right .seg.envs { display: none; }
}
