:root {
  --bg: #eef1f5;
  --bg-2: #e3e8ef;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #ccfbf1;
  --danger: #dc2626;
  --wa: #25d366;
  --mirror-1: #f8fafc;
  --mirror-2: #cbd5e1;
  --mirror-3: #e2e8f0;
  --frame: #64748b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --bg-2: #111a2e;
    --card: #131c31;
    --ink: #f1f5f9;
    --ink-2: #a5b4c8;
    --ink-3: #64748b;
    --line: #23304a;
    --accent: #2dd4bf;
    --accent-ink: #042f2e;
    --accent-soft: #134e4a;
    --mirror-1: #e2e8f0;
    --mirror-2: #64748b;
    --mirror-3: #94a3b8;
    --frame: #cbd5e1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(120px + var(--safe-b)); }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -16px; padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--mirror-1), var(--mirror-2));
  border: 1px solid var(--line);
  display: grid; place-items: center;
}
.brand-logo svg { width: 20px; height: 20px; color: var(--accent); }
.brand h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.brand p { font-size: 12.5px; margin: 0; color: var(--ink-2); }
.progress { display: flex; gap: 6px; margin-top: 12px; }
.progress span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); transition: background .3s; }
.progress span.on { background: var(--accent); }
.step-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 6px; font-weight: 600; }

/* ---------- Preview ---------- */
.preview {
  background: radial-gradient(120% 80% at 50% 0%, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 230px;
  transition: height .3s ease;
  display: grid; place-items: center;
  margin-top: 4px;
  position: relative; overflow: hidden;
}
.sticky-preview .preview { position: sticky; top: var(--top-h, 96px); z-index: 15; height: 190px; box-shadow: var(--shadow); }
.preview svg { width: 100%; height: 100%; }
.preview .tag {
  position: absolute; left: 12px; top: 12px;
  font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
}
.led-glow > g:first-child { animation: ledPulse 2.6s ease-in-out infinite; }
@keyframes ledPulse { 0%, 100% { opacity: .8; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .led-glow > g:first-child { animation: none; } }
.dim-text { font-size: 12px; font-weight: 700; fill: var(--ink-2); font-family: inherit; }
.dim-line { stroke: var(--ink-3); stroke-width: 1; }

/* ---------- Steps ---------- */
.step { display: none; animation: in .28s ease; }
.step.active { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.step h2 { font-size: 22px; letter-spacing: -.02em; margin: 22px 0 4px; }
.step .sub { color: var(--ink-2); font-size: 14px; margin: 0 0 16px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 22px 0 10px; }

/* Shape grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 420px) { .grid.three { grid-template-columns: repeat(3, 1fr); } }
.opt {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 14px 12px; text-align: left; position: relative;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.opt:active { transform: scale(.97); }
.opt.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt.sel::after {
  content: ''; position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/12px no-repeat;
}
.opt .ico { height: 58px; display: grid; place-items: center; margin-bottom: 8px; }
.opt .ico svg { height: 58px; width: 100%; }
.opt b { display: block; font-size: 15px; }
.opt small { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.opt.center { text-align: center; }
.shape-fill { fill: url(#mirrorGrad); stroke: var(--frame); stroke-width: 1.5; }

/* Measures */
.measure {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 10px 10px 10px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.measure:focus-within { border-color: var(--accent); }
.measure label { flex: 1; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.measure label span { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.measure .field { display: flex; align-items: baseline; gap: 4px; }
.measure input {
  width: 74px; border: 0; background: transparent; text-align: right;
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; outline: none; padding: 0;
  -moz-appearance: textfield;
}
.measure input::-webkit-outer-spin-button, .measure input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.measure .unit { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.stepper { display: flex; gap: 6px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--bg); font-size: 20px; font-weight: 600; color: var(--ink);
  display: grid; place-items: center;
}
.stepper button:active { background: var(--line); }
.err { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin: 2px 4px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.sel { border-color: var(--accent); background: var(--accent-soft); }
.info { font-size: 13px; color: var(--ink-2); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 10px 14px; margin-top: 12px; }

/* Extras list */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 13px 14px; text-align: left; box-shadow: var(--shadow);
  transition: border-color .15s;
}
.row.sel { border-color: var(--accent); }
.row .txt { flex: 1; min-width: 0; }
.row b { display: block; font-size: 15px; }
.row small { display: block; color: var(--ink-2); font-size: 12.5px; }
.row .price { font-size: 13px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.mark {
  width: 24px; height: 24px; flex: none; border: 2px solid var(--ink-3); border-radius: 7px;
  display: grid; place-items: center; transition: all .15s;
}
.mark.radio { border-radius: 50%; }
.row.sel .mark { background: var(--accent); border-color: var(--accent); }
.row.sel .mark::after { content: ''; width: 10px; height: 6px; border: solid var(--accent-ink); border-width: 0 0 2.5px 2.5px; transform: translateY(-1px) rotate(-45deg); }
.row.sel .mark.radio::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--accent-ink); transform: none; }
.row .stepper button { width: 34px; height: 34px; font-size: 18px; }
.row .qty { min-width: 22px; text-align: center; font-weight: 700; }

/* Summary */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.sum-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; }
.sum-line span:first-child { color: var(--ink-2); }
.sum-line span:last-child { font-weight: 600; text-align: right; }
.sum-total { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.sum-total b { font-size: 26px; letter-spacing: -.02em; }
.note { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 13px 14px; font-size: 16px; outline: none; margin-bottom: 10px;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.btn-wa {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--wa); color: #fff; border: 0; border-radius: 16px; padding: 16px;
  font-size: 16px; font-weight: 700; margin-top: 6px; text-decoration: none;
  box-shadow: 0 8px 20px rgba(37, 211, 102, .3);
}
.btn-wa svg { width: 22px; height: 22px; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 14px; padding: 12px 0; width: 100%; }

/* ---------- Bottom bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-b));
}
.bar-in { max-width: 528px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.bar .total { flex: 1; min-width: 0; }
.bar .total small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.bar .total b { font-size: 20px; letter-spacing: -.02em; white-space: nowrap; }
.btn {
  border: 0; border-radius: 14px; padding: 14px 22px; font-size: 15px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn.ghost { background: var(--bg); color: var(--ink); padding: 14px 16px; }
.hidden { display: none !important; }

/* ---------- Admin ---------- */
.admin .app { padding-bottom: calc(110px + var(--safe-b)); }
.adm-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.adm-card h3 { margin: 0 0 4px; font-size: 17px; }
.adm-card > p { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; }
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.fld .input { margin-bottom: 0; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--bg); }
.item .input { background: var(--card); padding: 10px 12px; font-size: 15px; }
.item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.item-head .input { flex: 1; font-weight: 700; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--danger); flex: none; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch i::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::before { transform: translateX(18px); }
.toggle-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 10px; font-size: 14px; font-weight: 600; }
.btn-add { width: 100%; border: 1.5px dashed var(--ink-3); background: transparent; border-radius: 14px; padding: 12px; font-weight: 700; color: var(--ink-2); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px -16px 0; padding: 0 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: var(--card); border: 1px solid var(--line); padding: 8px 14px; border-radius: 99px; font-weight: 700; font-size: 13.5px; color: var(--ink-2); }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: .25s; z-index: 50; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.warn { background: #fef3c7; color: #92400e; border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 600; margin-top: 12px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .adm-card { width: 100%; max-width: 380px; }

/* Marca MEK en el cotizador */
a.brand { color: inherit; text-decoration: none; }
.brand-logo.mek {
  background: linear-gradient(135deg, #14b8a6, #115e59); border: 0; color: #fff;
  box-shadow: 0 6px 16px -6px rgba(15,118,110,.7);
}
.brand-logo.mek svg { color: #fff; width: 20px; height: 20px; }
.mek-word { font-weight: 800; letter-spacing: .08em; color: var(--accent); }
.mek-sep { color: var(--ink-3); }
