/* Panel de gestion. Mobile-first: el duenio carga los precios desde el celular,
   asi que todo lo tocable mide al menos 48 px y no hay tablas que no entren. */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-deep); }

/* ---------- estructura ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(150deg, var(--green), var(--green-deep));
  display: grid; place-items: center; color: #fff; font-size: 21px;
}
.topbar h1 { font-size: 17px; font-weight: 800; margin: 0; line-height: 1.15; }
.topbar p { margin: 0; font-size: 12px; color: var(--ink-soft); }
.topbar .spacer { flex: 1; }

main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  appearance: none; border: 0; background: none; cursor: pointer;
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 700; color: var(--ink-faint);
}
.tabbar button span.ic { font-size: 20px; line-height: 1; }
.tabbar button[aria-current="true"] { color: var(--green-deep); }

/* ---------- bloques ---------- */
h2.sec { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin: 22px 2px 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.card > .head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .head .t { font-weight: 800; line-height: 1.2; }
.card > .head .s { font-size: 13px; color: var(--ink-soft); }
.card > .body { padding: 6px 0; }
.empty { padding: 22px 16px; color: var(--ink-soft); text-align: center; font-size: 14px; }

.rowitem {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; min-height: var(--tap);
  background: none; border: 0; border-top: 1px solid var(--line);
  text-align: left; cursor: pointer;
}
.card > .body > .rowitem:first-child { border-top: 0; }
.rowitem:active { background: var(--surface-2); }
.rowitem .t { font-weight: 700; }
.rowitem .s { font-size: 13px; color: var(--ink-soft); }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .chev { color: var(--ink-faint); font-size: 20px; }

.thumb {
  width: 46px; height: 46px; border-radius: 10px; flex: none; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; font-size: 24px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.pill { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.pill.live { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green-deep); }
.pill.warn { background: color-mix(in srgb, var(--tomato) 15%, transparent); color: var(--tomato); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }

/* ---------- botones ---------- */
.btn {
  appearance: none; cursor: pointer; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 700;
  min-height: var(--tap); padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(150deg, var(--green), var(--green-deep)); border-color: transparent; color: #fff; }
.btn.danger { color: var(--tomato); border-color: color-mix(in srgb, var(--tomato) 35%, var(--line)); }
.btn.wide { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow > .btn { flex: 1 1 140px; }
.iconbtn {
  appearance: none; cursor: pointer; width: 40px; height: 40px; flex: none;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 17px;
}

/* ---------- formularios ---------- */
.field { display: block; margin: 0 0 14px; }
.field > .lab { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field input[type="tel"], .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px;
}
.chip[aria-pressed="true"] { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--surface)); color: var(--green-deep); }
.chip .sw { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); }

.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tpl {
  appearance: none; cursor: pointer; padding: 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.tpl[aria-pressed="true"] { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); }
.tpl svg { width: 100%; height: 34px; display: block; margin-bottom: 6px; }
.tpl span { font-size: 12.5px; font-weight: 700; }

/* ---------- vista previa ---------- */
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.preview .dh-layer { opacity: 1; }
.previewnote { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }

/* ---------- items de placa ---------- */
.item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface);
}
.item .itemhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.item .itemhead .n { font-weight: 800; flex: 1; min-width: 0; }
.item .pick {
  appearance: none; cursor: pointer; display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: var(--tap); padding: 8px 12px; border: 1px dashed var(--line); border-radius: 12px;
  background: var(--surface-2); text-align: left; margin-bottom: 10px;
}
.item .pick .s { font-size: 12px; color: var(--ink-soft); }

/* ---------- hojas / modales ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sheet.on { display: block; }
.sheet > .head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet > .head .t { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet > .inner { padding: 16px 16px calc(40px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.sheet .footer { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); margin: 20px -16px calc(-40px - var(--safe-b)); }

/* ---------- link + QR ---------- */
.linkbox { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.linkbox code { flex: 1; min-width: 0; font-size: 13px; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.qrwrap { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: 12px; border: 1px solid var(--line); margin-top: 10px; }
.qrwrap[hidden] { display: none; }
.qrwrap svg { width: 190px; height: 190px; display: block; }
.qrwrap .fallback { color: #666; font-size: 13px; text-align: center; }

/* ---------- modales propios (nada de prompt/confirm del navegador) ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(12, 20, 14, .55); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 18px;
}
body.modal-open { overflow: hidden; }
.modal {
  width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 20px;
}
.modal h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; line-height: 1.2; }
.modal .msg { margin: 0 0 16px; font-size: 14px; color: var(--ink-soft); }
.modal .field:last-of-type { margin-bottom: 18px; }
.modal .btnrow > .btn { flex: 1 1 120px; }
.modal input[readonly] { background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- firma de Senta ---------- */
.sentatop { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); }
.sentatop .mk { width: 26px; height: 26px; flex: none; border-radius: 7px; object-fit: contain; }
.sentatop span { display: none; line-height: 1.15; font-size: 11px; }
.sentatop b { display: block; font-weight: 700; color: var(--ink-soft); }
.sentatop i { font-style: normal; letter-spacing: .04em; }
@media (min-width: 520px) { .sentatop span { display: block; } }

.sentafoot {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 30px 0 4px; padding-top: 20px; border-top: 1px solid var(--line);
  color: var(--ink-faint); font-size: 12.5px; line-height: 1.35; text-align: left;
}
.login .sentafoot { margin-top: 34px; }
.sentafoot .mk { width: 34px; height: 34px; flex: none; border-radius: 9px; object-fit: contain; }
.login .sentafoot .mk { width: 42px; height: 42px; border-radius: 11px; }
.sentafoot b { color: var(--ink-soft); }
.sentafoot a { color: var(--green-deep); text-decoration: none; font-weight: 700; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 340px; text-align: center; }
.login .mark { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; background: linear-gradient(150deg, var(--green), var(--green-deep)); display: grid; place-items: center; font-size: 32px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }
.pinview { font-size: 30px; letter-spacing: .5em; min-height: 46px; font-variant-numeric: tabular-nums; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pinpad button { min-height: 62px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; font-weight: 700; cursor: pointer; }
.pinerr { color: var(--tomato); font-size: 14px; font-weight: 700; min-height: 22px; margin-top: 10px; }

/* ---------- avisos ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(78px + var(--safe-b)); transform: translateX(-50%);
  z-index: 90; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); max-width: 88vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.on { opacity: 1; }
.toast.err { background: var(--tomato); color: #fff; }

.uploading { font-size: 13px; color: var(--ink-soft); }

/* ---------- escritorio ---------- */
@media (min-width: 860px) {
  main { padding-bottom: 40px; }
  .tabbar {
    position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
    max-width: 1100px; margin: 0 auto; grid-template-columns: repeat(4, minmax(0, 160px)); justify-content: start;
  }
  .tabbar button { flex-direction: row; gap: 8px; font-size: 14px; min-height: 52px; }
  .toast { bottom: 28px; }
  .sheet > .inner { padding-bottom: 60px; }
}

/* ---------- ingreso por email + contrasenia (multi-cuenta) ---------- */
#authForm { text-align: left; margin-top: 4px; }
#authForm .field { margin-bottom: 12px; }
#authForm input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font: inherit; font-size: 16px; /* 16px: iOS no hace zoom al enfocar */
}
#authForm input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
#authForm .btn { margin-top: 4px; }
.authswitch { margin-top: 14px; font-size: 14px; color: var(--ink-soft); line-height: 1.7; }
.authswitch button {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--green-deep); font: inherit; font-weight: 700; text-decoration: underline;
}
.authok { color: var(--green-deep); font-size: 14px; font-weight: 700; min-height: 22px; margin-top: 10px; }

/* ---------- avisos del estado de la cuenta ---------- */
#avisos { padding: 0 var(--pad); }
.aviso {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 11px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600; line-height: 1.45;
  background: #FFF6DA; color: #6b5310; border: 1px solid #F0DFAA;
}
.aviso.info { background: #E8F5EE; color: #17553a; border-color: #C9E6D6; }
.aviso .grow { flex: 1 1 180px; }
.aviso button {
  appearance: none; cursor: pointer; border: 1px solid currentColor; background: transparent;
  color: inherit; font: inherit; font-weight: 700; border-radius: 999px; padding: 6px 14px;
}

/* Contraseña con boton ver/ocultar */
.pw { position: relative; display: block; }
.pw input { padding-right: 76px !important; }
.pweye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--green-deep); font: inherit; font-size: 14px; font-weight: 700;
  padding: 8px 10px; border-radius: 8px; min-height: 36px;
}
.pweye:hover { background: var(--surface-2, rgba(0,0,0,.04)); }

/* ---------- hoja "Cómo se usa" ---------- */
.body.ayuda { padding: 14px 16px; font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); }
.body.ayuda p { margin: 0 0 10px; }
.body.ayuda p:last-child { margin-bottom: 0; }
.body.ayuda b { color: var(--ink); }
.body.ayuda ul { margin: 0; padding-left: 18px; }
.body.ayuda li { margin-bottom: 9px; }
.body.ayuda li:last-child { margin-bottom: 0; }
.paso { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.paso:first-child { border-top: 0; padding-top: 2px; }
.paso:last-child { padding-bottom: 2px; }
.paso .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--green); color: #fff; font-weight: 800; font-size: 15px;
  display: grid; place-items: center;
}
.paso b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- planes de suscripción ---------- */
.planes { display: grid; gap: 10px; }
.plan {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
}
.plan.mio { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.plan.sug { border-color: var(--green); }
.plan .tvs {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--green); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.plan .t { display: block; font-weight: 700; font-size: 15px; }
.plan .s { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.plan .tag {
  font-size: 11px; font-weight: 700; color: var(--green-deep);
  background: #E8F5EE; border-radius: 999px; padding: 2px 8px; vertical-align: middle;
}
.plan .actual { font-size: 13px; font-weight: 700; color: var(--green-deep); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.plan.mas { border-style: dashed; background: transparent; }
.plan.mas .tvs { background: var(--ink-faint, #9aa5a0); }
.plan.mas .btn { text-decoration: none; display: inline-flex; align-items: center; }
