:root {
  --bg: #f7f3f6; --panel: #fff; --line: #ebe2e8; --ink: #2d1f28; --muted: #85707d;
  --pri: #b84d77; --pri2: #8b2f55; --gold: #c9a24a; --ok: #2e8b57; --bad: #c0392b;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 500; white-space: nowrap; transition: .15s; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--pri); color: var(--pri); }
.btn.primary { background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger:hover { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.wa { background: #25d366; color: #fff; border-color: transparent; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 0, #f4d6e2, var(--bg) 60%); }
.login-card { width: min(360px, 100%); background: #fff; border-radius: 20px; padding: 32px 26px; text-align: center; box-shadow: 0 30px 60px -30px rgba(139,47,85,.4); display: grid; gap: 12px; }
.login-crown { font-size: 40px; }
.login h1 { font-family: Cinzel, serif; font-weight: 500; margin: 0; letter-spacing: .06em; }
.login p { margin: 0; color: var(--muted); }
.login input { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); }
.err { color: var(--bad) !important; min-height: 1em; }

/* topbar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-family: Cinzel, serif; font-size: 16px; letter-spacing: .05em; display: flex; gap: 6px; align-items: center; }
#invSelect { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); max-width: 260px; background: #fff; }
.top-actions { display: flex; gap: 6px; }
.status { margin-left: auto; color: var(--muted); font-size: 12px; }
.status.dirty { color: #b5651d; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; height: calc(100vh - 57px); }
.panel-form { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 12px 12px 80px; }
.panel-right { display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); background: #fff; }
.tabs button { border: 0; background: none; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs button.on { color: var(--pri2); border-bottom-color: var(--pri); }
.tab { flex: 1; overflow: auto; }

/* secciones del formulario */
details.sec { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; background: #fff; }
details.sec[open] { box-shadow: 0 8px 20px -18px rgba(0,0,0,.4); }
details.sec > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: .2s; }
details.sec:not([open]) > summary::after { transform: rotate(-90deg); }
details.sec.off > summary .ttl { color: var(--muted); text-decoration: line-through; }
.sec-body { padding: 4px 14px 14px; display: grid; gap: 12px; }
.fld { display: grid; gap: 5px; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fld small { color: var(--muted); font-size: 12px; }
.fld input[type=text], .fld input[type=url], .fld input[type=date], .fld input[type=time], .fld input[type=number], .fld select, .fld textarea, .inp {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(184,77,119,.12); }
.fld textarea { resize: vertical; min-height: 64px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }

/* switch */
.sw { position: relative; width: 38px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; border-radius: 99px; background: #d9cfd5; transition: .2s; }
.sw span::after { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sw input:checked + span { background: var(--pri); }
.sw input:checked + span::after { transform: translateX(16px); }
.fld-toggle { display: flex; align-items: center; gap: 10px; }

/* temas */
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme { border: 2px solid transparent; border-radius: 10px; padding: 6px; background: #faf7f9; display: grid; gap: 4px; font-size: 11px; text-align: center; }
.theme.on { border-color: var(--pri); background: #fff; }
.theme i { display: flex; height: 26px; border-radius: 6px; overflow: hidden; }
.theme i b { flex: 1; }

/* slug */
.slug { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.slug span { padding: 9px 0 9px 11px; color: var(--muted); white-space: nowrap; }
.slug input { border: 0 !important; box-shadow: none !important; padding-left: 2px !important; }

/* media */
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #f3edf1 center/cover; border: 1px solid var(--line); flex: none; }
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.gal-it { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #f3edf1; }
.gal-it img { width: 100%; height: 100%; object-fit: cover; }
.gal-it .ctl { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: linear-gradient(transparent, rgba(0,0,0,.6)); padding: 4px; }
.gal-it .ctl button { border: 0; background: rgba(255,255,255,.9); border-radius: 6px; width: 24px; height: 24px; font-size: 12px; padding: 0; }
.gal-add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; background: none; color: var(--muted); font-size: 12px; }
.gal-add:hover { border-color: var(--pri); color: var(--pri); }
audio { width: 100%; height: 36px; }

/* listas */
.lst { display: grid; gap: 8px; }
.lst-it { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; background: #fcfafb; }
.lst-head { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.lst-head .sp { flex: 1; }
.ib { border: 1px solid var(--line); background: #fff; width: 28px; height: 28px; border-radius: 8px; padding: 0; }
.ib:hover { border-color: var(--pri); color: var(--pri); }
.add { border: 1px dashed var(--pri); color: var(--pri); background: #fff; border-radius: 9px; padding: 8px; font-weight: 500; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.color-it { display: flex; align-items: center; gap: 2px; }
input[type=color] { width: 40px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }

/* vista previa */
.pv-tools { display: flex; justify-content: center; gap: 10px; padding: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); }
.seg button.on { background: var(--pri); color: #fff; }
.stage { display: flex; justify-content: center; padding: 0 16px 24px; height: calc(100% - 60px); }
.device { background: #fff; overflow: hidden; transition: .3s; height: 100%; }
.device.mobile { width: 390px; max-height: 820px; border-radius: 36px; border: 10px solid #1f1a1e; box-shadow: 0 30px 60px -30px rgba(0,0,0,.5); }
.device.desktop { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.device iframe { width: 100%; height: 100%; border: 0; display: block; }

/* modo envío y confirmaciones */
.pane { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 16px; }
.box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 12px; }
.box h3 { margin: 0; font-family: Cinzel, serif; font-weight: 500; letter-spacing: .04em; }
.box p { margin: 0; color: var(--muted); }
.link-big { font-size: 16px; font-weight: 600; color: var(--pri2); word-break: break-all; }
.send-grid { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.qr { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.qr img, .qr canvas { display: block; width: 160px !important; height: 160px !important; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tbl-wrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat b { display: block; font-size: 26px; font-family: Cinzel, serif; color: var(--pri2); }
.stat span { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.si { background: #e3f4ea; color: var(--ok); }
.pill.no { background: #fbe7e5; color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 20px; background: #2d1f28; color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; z-index: 99; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; translate: -50% 0; }
.toast.bad { background: var(--bad); }

.mbar { display: none; }

@media (max-width: 900px) {
  .top { gap: 6px; padding: 8px 12px; }
  .brand { display: none; }
  #invSelect { flex: 1; max-width: none; }
  .status { order: 5; width: 100%; margin: 0; }
  .top-actions .btn, .top .btn { padding: 7px 10px; font-size: 13px; }
  .layout { display: block; height: auto; }
  .panel-form { border: 0; padding-bottom: 90px; }
  .panel-right { min-height: calc(100vh - 110px); padding-bottom: 70px; }
  body.m-edit .panel-right, body.m-view .panel-form { display: none; }
  .stage { height: 75vh; }
  .device.mobile { width: 100%; max-width: 390px; }
  .send-grid { grid-template-columns: 1fr; }
  .mbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 20; }
  .mbar button { flex: 1; border: 0; background: none; padding: 14px; font-weight: 600; color: var(--muted); }
  .mbar button.on { color: var(--pri2); }
}
