:root {
  --ink: #1e293b;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --green: #82c91e;
  --yellow: #fab005;
  --blue: #228be6;
  --red: #e03131;
  --wa: #25d366;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* HEADER */
.top {
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; border-bottom: 4px solid var(--green); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-logo { height: 36px; background: #fff; border-radius: 8px; padding: 3px 6px; }
.brand-title { font-weight: 800; letter-spacing: .4px; font-size: 1rem; }
.brand-sub { font-size: .75rem; opacity: .75; }
.promo { list-style: none; display: flex; gap: 14px; margin-left: auto; font-size: .8rem; font-weight: 600; }
.promo li { background: rgba(255,255,255,.08); padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.mobile-tabs { display: none; }
.foto-btn {
  background: #fff; color: var(--ink); text-decoration: none; font-weight: 700; font-size: .82rem;
  padding: 7px 14px; border-radius: 99px; white-space: nowrap; border: 2px solid var(--green);
}
.foto-btn:hover { background: var(--green); color: #0f2900; }

/* LAYOUT */
.app { flex: 1; display: grid; grid-template-columns: 300px 1fr 330px; min-height: 0; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.catalog { border-right: 1px solid var(--line); }
.summary { border-left: 1px solid var(--line); padding: 14px; gap: 12px; overflow-y: auto; }

/* CATÁLOGO */
.catalog-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
#search { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats button {
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 4px 10px; font-size: .78rem; color: var(--ink-2);
}
.cats button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.catalog-list { flex: 1; overflow-y: auto; padding: 10px; display: grid; gap: 8px; align-content: start; }
.card {
  display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: #fff;
  text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(15,23,42,.08); transform: translateY(-1px); }
.card img { width: 72px; height: 72px; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.card .n { font-weight: 700; font-size: .86rem; line-height: 1.2; }
.card .m { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.card .p { font-size: .86rem; font-weight: 800; color: var(--blue); margin-top: 3px; }
.card .p small { color: #2f9e44; font-weight: 700; display: block; font-size: .72rem; }

/* ESCENARIO */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto;
  padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line);
}
@media (max-width: 820px) { .toolbar { flex-wrap: wrap; } }
.toolbar > button, .seg button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 6px 9px; font-size: .8rem; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.toolbar > button:hover { background: var(--bg); }
.toolbar > button:disabled { opacity: .4; cursor: default; }
.toolbar .danger { color: var(--red); }
.toolbar .ghost { color: var(--muted); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; border-left: 0; }
.seg button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.room { font-size: .8rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.room input { width: 62px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.viewport { position: relative; flex: 1; min-height: 0; background: #e9eef3; }
#plan, #view3d { position: absolute; inset: 0; width: 100%; height: 100%; }
#plan { touch-action: none; display: block; }
#view3d canvas { display: block; }
.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(30,41,59,.85); color: #fff; font-size: .8rem;
  padding: 7px 14px; border-radius: 99px; pointer-events: none; white-space: nowrap;
}

/* SELECCIÓN */
.selection { border: 1px dashed #cbd5e1; border-radius: var(--radius); padding: 10px; font-size: .84rem; color: var(--ink-2); }
.selection .empty { font-style: italic; }
.sel-head { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: center; }
.sel-head img { width: 84px; height: 84px; object-fit: contain; background: #f8fafc; border-radius: 8px; }
.sel-head b { color: var(--ink); font-size: .92rem; display: block; }
.sel-head a { font-size: .75rem; color: var(--blue); }
.field { margin-top: 10px; }
.field > span { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 5px; }
.opts { display: flex; flex-wrap: wrap; gap: 5px; }
.opts button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 8px; font-size: .78rem; }
.opts button.on { border-color: var(--blue); background: #e7f5ff; color: #1864ab; font-weight: 700; }
.opts button:disabled { opacity: .35; cursor: default; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; padding: 0 !important; }
.sw.on { box-shadow: 0 0 0 2px var(--blue); }
.note { margin-top: 8px; font-size: .76rem; background: #fff9db; color: #8a6d00; border-radius: 6px; padding: 6px 8px; }
.warn { margin-top: 8px; font-size: .76rem; background: #fff5f5; color: var(--red); border-radius: 6px; padding: 6px 8px; }

/* PRESUPUESTO */
.sum-title { font-size: 1rem; border-bottom: 2px solid var(--green); padding-bottom: 6px; }
.lines { list-style: none; display: grid; gap: 6px; font-size: .8rem; align-content: start; flex: 1 1 auto; min-height: 60px; overflow-y: auto; }
.summary > :not(.lines) { flex-shrink: 0; }
.lines li { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 6px 8px; border-radius: 6px; background: var(--bg); cursor: pointer; }
.lines li.on { outline: 2px solid var(--blue); }
.lines li small { color: var(--muted); display: block; }
.lines .empty { background: none; color: var(--muted); font-style: italic; cursor: default; }
.totals { background: var(--bg); border-radius: var(--radius); padding: 12px; display: grid; gap: 6px; font-size: .84rem; }
.totals .row { display: flex; justify-content: space-between; gap: 8px; }
.totals .big { font-size: 1.05rem; border-top: 1px solid #cbd5e1; padding-top: 8px; color: var(--ink); }
.totals .big em { font-style: normal; color: #2f9e44; font-size: .78rem; }
.totals .save { color: #2f9e44; font-weight: 700; }
.lines .lp { text-align: right; white-space: nowrap; }
.lines .lp b { color: #2f9e44; }
.lines .lp b.quote, .card .p small.quote { color: #e67700; }
.pb-quote { color: #e67700; font-weight: 600; font-size: .9em; }
.cta-wa {
  display: block; margin-top: 10px; text-align: center; text-decoration: none;
  background: #25D366; color: #fff; font-weight: 800; border-radius: 8px; padding: 9px 10px; font-size: .86rem;
}
.cta-wa:hover { filter: brightness(.95); }
.fine { font-size: .72rem; color: var(--muted); text-align: center; }

/* BARRA FIJA DEL PROYECTO */
.projbar {
  position: relative; flex-shrink: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(15,23,42,.08);
}
.pb-info { flex: 1; min-width: 0; }
.pb-total { font-size: 1rem; color: var(--ink); line-height: 1.3; }
.pb-total b { font-size: 1.15rem; font-weight: 800; }
.pb-dot { color: var(--muted); margin: 0 2px; }
.pb-cuotas { color: var(--ink-2); }
.pb-note { font-size: .72rem; color: #868e96; margin-top: 2px; }
.pb-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.pb-wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #25D366; color: #fff; border: 0; border-radius: 12px;
  padding: 13px 22px; font-weight: 800; font-size: 1.02rem;
  box-shadow: 0 6px 16px rgba(37,211,102,.35);
}
.pb-wa:hover { filter: brightness(.95); }
.pb-wa:active { transform: translateY(1px); }
.pb-cart {
  background: #fff; color: var(--ink); border: 1.5px solid var(--ink);
  border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: .85rem;
}
.pb-cart:hover { background: var(--bg); }
.projbar [hidden] { display: none !important; }
.toast {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: .85rem; padding: 8px 14px; border-radius: 99px;
  white-space: nowrap; box-shadow: 0 6px 16px rgba(15,23,42,.25); transition: opacity .25s;
  max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.toast b { color: #8ce99a; }
.toast.out { opacity: 0; }

/* MOBILE */
@media (max-width: 1100px) {
  .app { grid-template-columns: 260px 1fr 290px; }
  .promo { display: none; }
  .foto-btn { margin-left: auto; }
}
@media (max-width: 820px) {
  .top { padding: 8px 12px; }
  .mobile-tabs { display: flex; width: 100%; gap: 4px; }
  .mobile-tabs button { flex: 1; border: 0; border-radius: 7px; padding: 7px; background: rgba(255,255,255,.1); color: #fff; font-weight: 600; font-size: .85rem; }
  .mobile-tabs button.active { background: var(--green); color: #0f2900; }
  .mobile-tabs span { background: #fff; color: var(--ink); border-radius: 99px; padding: 0 6px; font-size: .72rem; }
  .app { display: block; position: relative; }
  .app > * { position: absolute; inset: 0; display: none; }
  .app > .show { display: flex; }
  .toolbar .room { order: 10; }
  .projbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .pb-total { font-size: .92rem; }
  .pb-total b { font-size: 1.05rem; }
  .pb-cuotas { white-space: nowrap; }
  .pb-dot { display: none; }
  .pb-cuotas { display: block; }
  .pb-note { font-size: .68rem; }
  .pb-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .pb-wa { width: 100%; padding: 14px 16px; font-size: 1.05rem; white-space: nowrap; }
  .pb-cart { width: 100%; padding: 8px 12px; font-size: .85rem; }
  .hint { white-space: normal; text-align: center; width: calc(100% - 32px); }
}
