/* ==========================================================================
   METAFORM — Hoja de estilos única.
   Móvil primero; a partir de 900px se activa la disposición de escritorio
   (barra lateral fija en vez de barra inferior, rejillas de 2-3 columnas).
   ========================================================================== */

:root {
  --acc:        #7c5cff;
  --acc-2:      #5b8cff;
  --acc-soft:   rgba(124, 92, 255, .12);
  --acc-ink:    #ffffff;

  --ok:         #10b981;
  --warn:       #f59e0b;
  --bad:        #ef4444;

  --bg:         #f4f5fb;
  --bg-2:       #ffffff;
  --card:       #ffffff;
  --card-2:     #fafaff;
  --ink:        #14161f;
  --ink-2:      #5b6172;
  --ink-3:      #8b90a1;
  --line:       #e5e7f0;
  --line-2:     #eef0f7;

  --sh-1: 0 1px 2px rgba(19,22,40,.06), 0 1px 3px rgba(19,22,40,.05);
  --sh-2: 0 4px 12px rgba(19,22,40,.07), 0 2px 4px rgba(19,22,40,.04);
  --sh-3: 0 18px 44px rgba(19,22,40,.16);

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-full: 999px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 64px;
  --side-w: 244px;
}

:root[data-theme="dark"], html:not([data-theme="light"]) body.force-dark {
  --bg:      #0e1017;
  --bg-2:    #151824;
  --card:    #171a27;
  --card-2:  #1d2130;
  --ink:     #eef0f7;
  --ink-2:   #a8adc0;
  --ink-3:   #767c92;
  --line:    #262a3b;
  --line-2:  #202432;
  --acc-soft: rgba(124, 92, 255, .18);
  --sh-1: 0 1px 2px rgba(0,0,0,.35);
  --sh-2: 0 6px 16px rgba(0,0,0,.4);
  --sh-3: 0 22px 50px rgba(0,0,0,.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #0e1017;
    --bg-2:    #151824;
    --card:    #171a27;
    --card-2:  #1d2130;
    --ink:     #eef0f7;
    --ink-2:   #a8adc0;
    --ink-3:   #767c92;
    --line:    #262a3b;
    --line-2:  #202432;
    --acc-soft: rgba(124, 92, 255, .18);
    --sh-1: 0 1px 2px rgba(0,0,0,.35);
    --sh-2: 0 6px 16px rgba(0,0,0,.4);
    --sh-3: 0 22px 50px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: var(--acc); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }

/* ------------------------------------------------------------------ Marca */
.brand-badge {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(140deg, var(--acc), var(--acc-2));
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 12px rgba(124,92,255,.35);
}

/* ==================================================================
   Pantallas de acceso (login / instalador)
   ================================================================== */
.body-auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(124,92,255,.20), transparent 60%),
    radial-gradient(700px 500px at 110% 10%, rgba(91,140,255,.18), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--sh-3);
  padding: 28px 24px calc(28px + var(--safe-b));
}
.auth-wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .04em; margin-bottom: 18px; }
.auth-title { font-size: 25px; margin-bottom: 6px; }
.auth-sub { color: var(--ink-2); font-size: 14.5px; margin: 0 0 18px; }
.auth-sub.warn { color: var(--warn); }
.code-box {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 12px; font-size: 12.5px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 16px;
}

/* ==================================================================
   Estructura principal (admin)
   ================================================================== */
.shell { min-height: 100dvh; }
.app {
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  min-height: 100dvh;
}

/* --- Barra superior móvil --- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .tb-act { display: flex; gap: 8px; align-items: center; }
.topbar .tb-act:empty { display: none; }
/* En móvil basta con el botón de salir: el nombre robaría sitio al título. */
.tb-user { display: none; }
@media (min-width: 560px) {
  .tb-user {
    display: block;
    font-size: 13.5px; font-weight: 600; color: var(--ink-2);
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--r-s);
  background: var(--card); border: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer; font-size: 17px;
  transition: .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--acc); }

/* --- Barra lateral (escritorio) --- */
.sidebar { display: none; }

/* --- Barra inferior (móvil) --- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-3); font-size: 10.5px; font-weight: 600;
  text-decoration: none; padding-top: 4px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--acc); }
.bn-item.center .bn-plus {
  width: 46px; height: 46px; border-radius: 15px; margin-top: -14px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--acc), var(--acc-2));
  box-shadow: 0 8px 20px rgba(124,92,255,.45);
}

/* ==================================================================
   Contenido
   ================================================================== */
.page { padding: 16px; max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; }
.page-head p { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; }
.page-head .grow { flex: 1; min-width: 180px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--sh-1);
  padding: 16px;
  margin-bottom: 14px;
}
.card-t { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-t .sub { font-weight: 500; color: var(--ink-3); font-size: 13px; margin-left: auto; }
.card.flat { box-shadow: none; background: var(--card-2); }

.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.grid-auto { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 14px; box-shadow: var(--sh-1);
}
.stat .lab { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .val { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.stat .val.sm { font-size: 18px; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .ic { font-size: 42px; display: block; margin-bottom: 10px; }
.empty h3 { color: var(--ink-2); font-size: 16px; margin-bottom: 6px; }

/* ==================================================================
   Botones
   ================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: var(--r-s); padding: 11px 16px;
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .15s, background .15s, border-color .15s;
  min-height: 44px;
}
.btn:active { transform: scale(.985); }
.btn svg { width: 19px; height: 19px; flex: 0 0 19px; }
.icon-btn svg { width: 19px; height: 19px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(140deg, var(--acc), var(--acc-2));
  border-color: transparent; color: var(--acc-ink);
  box-shadow: 0 6px 16px rgba(124,92,255,.32);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(124,92,255,.42); }
.btn-ghost { background: transparent; }
.btn-soft { background: var(--acc-soft); border-color: transparent; color: var(--acc); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; min-height: 36px; border-radius: 9px; }
.btn-lg { padding: 15px 22px; font-size: 17px; min-height: 54px; border-radius: var(--r-m); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }

/* ==================================================================
   Formularios
   ================================================================== */
.form-grid { display: grid; gap: 14px; }
.form-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 6px; }
.row-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.field .req { color: var(--bad); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=search], input:not([type]), select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-s);
  color: var(--ink);
  font: inherit; font-size: 16px;           /* 16px evita el zoom automático en iOS */
  padding: 12px 13px;
  min-height: 48px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b90a1' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 17px;
  padding-right: 38px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--acc);
  box-shadow: 0 0 0 3.5px var(--acc-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[readonly] { background: var(--card-2); color: var(--ink-2); }

.check, .radio {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; cursor: pointer; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: var(--r-s);
  background: var(--bg-2); min-height: 48px;
}
.check input, .radio input { width: 20px; height: 20px; accent-color: var(--acc); flex: 0 0 20px; margin: 0; }
.check:has(input:checked), .radio:has(input:checked) { border-color: var(--acc); background: var(--acc-soft); }
.check-plain { border: none; background: none; padding: 4px 0; min-height: 0; }
.check-list { display: grid; gap: 8px; }

/* Interruptor */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.switch input { display: none; }
.switch .track {
  width: 46px; height: 27px; border-radius: var(--r-full); background: var(--line);
  position: relative; transition: background .18s; flex: 0 0 46px;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .18s;
}
.switch input:checked + .track { background: var(--acc); }
.switch input:checked + .track::after { transform: translateX(19px); }

/* Grupo importe: número + moneda */
.money-row { display: flex; gap: 8px; }
.money-row input { flex: 1; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 18px; }
.money-row select { width: auto; min-width: 104px; flex: 0 0 auto; font-weight: 600; }

.alert { border-radius: var(--r-s); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; border: 1px solid; }
.alert-error { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.alert-ok    { background: color-mix(in srgb, var(--ok) 12%, transparent);  border-color: color-mix(in srgb, var(--ok) 35%, transparent);  color: var(--ok); }
.alert-info  { background: var(--acc-soft); border-color: transparent; color: var(--acc); }

/* ==================================================================
   Etiquetas, tablas, listas
   ================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700;
  background: var(--acc-soft); color: var(--acc);
}
.badge.gray { background: var(--line-2); color: var(--ink-2); }
.badge.ok   { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.bad  { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #b45309; }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
table.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 700; padding: 11px 12px;
  border-bottom: 1px solid var(--line); background: var(--card-2);
  position: sticky; top: 0;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--card-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tfoot td { font-weight: 800; background: var(--card-2); border-top: 2px solid var(--line); }

.list { display: grid; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 13px 14px; box-shadow: var(--sh-1); text-decoration: none; color: inherit;
  min-width: 0;   /* como hijo de rejilla, sin esto no puede encoger y desborda */
}
.list-item .ic {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--ink-2);
}
.list-item .ic svg { width: 18px; height: 18px; }
/* Monograma: iniciales en vez de icono, para tiendas y formularios */
.list-item .ic.mono { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink-2); }
/* Punto de color: la única pincelada de color que identifica una tienda */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; margin-right: 6px; vertical-align: 1px; }
.list-item .bd { flex: 1; min-width: 0; }
.list-item .bd .t { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .bd .s { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .bd .hint-line { font-size: 12px; opacity: .8; }
.list-item .go { color: var(--ink-3); font-size: 20px; flex: 0 0 auto; }
.list-item.dim { opacity: .55; }

/* Hueco derecho de la tarjeta: importe, fecha, contador… */
.list-item .end { flex: 0 0 auto; text-align: right; min-width: 0; }
.list-item .end .top { display: block; font-size: 13.5px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-item .end .bot { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; margin-top: 2px; }
.list-item .end .top.big { font-size: 15.5px; font-weight: 800; letter-spacing: -.02em; }

/* Tarjeta pulsable (abre detalle) */
.list-item.tap { cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.list-item.tap:active { background: var(--card-2); transform: scale(.995); }
.list-item.tap:hover { border-color: var(--acc); }

/* Cabecera de grupo dentro de una lista de tarjetas */
.list-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 2px 2px;
}
.list-head .n { margin-left: auto; letter-spacing: 0; text-transform: none; font-weight: 600; }

/* En móvil las tarjetas se aprietan un poco */
@media (max-width: 560px) {
  .list { gap: 8px; }
  .list-item { padding: 11px 12px; gap: 10px; border-radius: 13px; }
  .list-item .ic { width: 38px; height: 38px; flex: 0 0 38px; font-size: 18px; border-radius: 11px; }
  .list-item .bd .t { font-size: 14.5px; }
  .list-item .bd .s { font-size: 12px; }
}

/* ==================================================================
   Apuntador: elegir tienda / formulario
   ================================================================== */
.pick-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.pick {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-m);
  padding: 18px 16px; box-shadow: var(--sh-1); cursor: pointer; color: inherit;
  font: inherit; width: 100%; transition: .15s;
}
.pick:hover, .pick:focus-visible { border-color: var(--acc); box-shadow: var(--sh-2); outline: none; }
.pick .ic { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; }
.pick .t { font-weight: 700; font-size: 17px; }
.pick .s { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }

/* ==================================================================
   Apuntador: relleno del formulario
   ================================================================== */
.fill-wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 140px; }

.fill-head { padding: 18px 0 6px; }
.fill-head .kicker { font-size: 12.5px; font-weight: 700; color: var(--acc); text-transform: uppercase; letter-spacing: .06em; }
.fill-head h2 { font-size: 23px; margin-top: 4px; }
.fill-head p { color: var(--ink-2); font-size: 14.5px; margin: 6px 0 0; }

.progress { height: 6px; border-radius: var(--r-full); background: var(--line); overflow: hidden; margin: 14px 0 4px; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--acc), var(--acc-2)); transition: width .3s ease; }
.progress-lab { font-size: 12.5px; color: var(--ink-3); font-weight: 600; text-align: right; }

.sec-panel { display: none; }
.sec-panel.on { display: block; animation: slideIn .22s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.sec-title { font-size: 18px; margin: 20px 0 2px; }
.sec-desc { color: var(--ink-2); font-size: 14px; margin: 0 0 4px; }

.q {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 16px; margin: 12px 0; box-shadow: var(--sh-1);
}
.q.err { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 14%, transparent); }
.q-lab { font-size: 15.5px; font-weight: 700; margin-bottom: 3px; }
.q-help { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.q-body { margin-top: 10px; }
.q-msg { color: var(--bad); font-size: 13px; font-weight: 600; margin-top: 8px; display: none; }
.q.err .q-msg { display: block; }

/* Adjuntar foto */
.photo {
  margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px;
}
.photo-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px dashed var(--line); background: var(--bg-2); color: var(--ink-2);
  border-radius: var(--r-s); padding: 10px 14px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; min-height: 44px;
}
.photo-btn:hover { border-color: var(--acc); color: var(--acc); }
.photo input[type=file] { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb {
  position: relative; width: 84px; height: 84px; border-radius: var(--r-s);
  overflow: hidden; border: 1px solid var(--line); background: var(--card-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px;
  border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}

/* Barra de acción fija al pie del formulario */
.fill-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; gap: 10px; align-items: center;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.fill-bar .btn { flex: 1; }
.fill-bar .btn.grow-2 { flex: 2; }

/* Pantalla de envío correcto */
.done { text-align: center; padding: 60px 20px; }
.done .tick {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 20px;
  display: grid; place-items: center; font-size: 42px; color: #fff;
  background: linear-gradient(140deg, var(--ok), #34d399);
  box-shadow: 0 12px 30px rgba(16,185,129,.4);
  animation: pop .4s cubic-bezier(.2,1.4,.5,1);
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
.done h2 { font-size: 24px; margin-bottom: 8px; }
.done p { color: var(--ink-2); margin: 0 0 24px; }

/* ==================================================================
   Editor de formularios
   ================================================================== */
.ed-sec {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  margin-bottom: 14px; box-shadow: var(--sh-1); overflow: hidden;
}
.ed-sec-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--card-2); border-bottom: 1px solid var(--line);
}
.ed-sec-head .n {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--acc); color: #fff; font-size: 12.5px; font-weight: 800;
}
.ed-sec-head input { border: none; background: transparent; font-weight: 700; font-size: 15.5px; padding: 6px 8px; min-height: 40px; }
.ed-sec-head input:focus { background: var(--bg-2); box-shadow: none; border: 1.5px solid var(--acc); }
.ed-sec-body { padding: 12px 14px; }

.ed-q {
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 12px; margin-bottom: 10px; background: var(--bg-2);
}
.ed-q-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ed-q-top .tipo { flex: 0 0 168px; }
.ed-q-top .etq { flex: 1; min-width: 160px; }
.ed-q-cfg { margin-top: 10px; display: grid; gap: 10px; }
.ed-q-flags { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ed-opts { display: grid; gap: 6px; }
.ed-opt { display: flex; gap: 6px; align-items: center; }
.ed-opt input { min-height: 42px; }
.ed-opt .del { flex: 0 0 38px; }
.drag-h { cursor: grab; color: var(--ink-3); font-size: 17px; padding: 0 2px; user-select: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-full); cursor: pointer;
  border: 1.5px solid var(--line); background: var(--bg-2);
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) { border-color: var(--acc); background: var(--acc-soft); color: var(--acc); }

/* ==================================================================
   Ventanas modales
   ================================================================== */
.modal-bg {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,12,20,.55);
  backdrop-filter: blur(3px);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-bg.on { display: flex; }
.modal {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: var(--sh-3);
  max-height: 92dvh; display: flex; flex-direction: column;
  animation: up .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  display: flex; gap: 10px; padding: 14px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--card-2);
}
.modal-foot .btn { flex: 1; }

/* Detalle de una respuesta */
.det-row { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.det-row:last-child { border-bottom: none; }
.det-row .k { flex: 0 0 40%; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.det-row .v { flex: 1; font-size: 14.5px; font-weight: 600; word-break: break-word; }
.det-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--acc); font-weight: 800; margin: 16px 0 2px; }
.det-fotos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.det-fotos a { display: block; width: 74px; height: 74px; border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); }
.det-fotos img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Filtros */
.filtros { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.filtros .full { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px); z-index: 200;
  background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: var(--r-full);
  font-size: 14.5px; font-weight: 600; box-shadow: var(--sh-3);
  opacity: 0; pointer-events: none; transition: .25s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.hide { display: none !important; }

/* ==================================================================
   ESCRITORIO — a partir de 900px
   ================================================================== */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100dvh; }
  .app { padding-bottom: 40px; }
  .bottom-nav { display: none; }
  .topbar { padding: 16px 28px; background: transparent; backdrop-filter: none; border-bottom: 1px solid var(--line); }
  .topbar h1 { font-size: 20px; }
  .page { padding: 22px 28px 40px; }

  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh;
    background: var(--bg-2); border-right: 1px solid var(--line);
    padding: 20px 14px; overflow-y: auto;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .04em; color: var(--ink); padding: 0 8px 18px; }
  .side-new { margin-bottom: 14px; }
  .side-nav { display: grid; gap: 3px; }
  .side-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--r-s);
    color: var(--ink-2); font-size: 14.5px; font-weight: 600; text-decoration: none;
  }
  .side-link svg { width: 19px; height: 19px; flex: 0 0 19px; }
  .side-link:hover { background: var(--card-2); color: var(--ink); }
  .side-link.active { background: var(--acc-soft); color: var(--acc); }
  .side-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; padding: 16px 12px 6px; }
  .side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
  .side-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
  .side-avatar {
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 800; font-size: 14px;
    background: linear-gradient(140deg, var(--acc), var(--acc-2)); color: #fff;
  }
  .side-uname { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-urol { font-size: 12px; color: var(--ink-3); }
  .theme-row { display: flex; gap: 4px; margin-top: 10px; }
  .theme-row button {
    flex: 1; padding: 7px 4px; font-size: 11.5px; font-weight: 600; cursor: pointer;
    background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2);
  }
  .theme-row button.on { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); }

  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .row-3 { grid-template-columns: repeat(3, 1fr); }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .filtros { grid-template-columns: repeat(4, 1fr); }
  .filtros .full { grid-column: auto; }

  /* Modales centrados en escritorio */
  .modal-bg { align-items: center; padding: 24px; }
  .modal { border-radius: var(--r-l); max-height: 86dvh; }
  .modal-foot { padding-bottom: 14px; }
  .modal-foot .btn { flex: 0 0 auto; }
  .modal-foot { justify-content: flex-end; }

  /* En PC el formulario se ve entero, sin pasos */
  .fill-wrap { max-width: 880px; padding-bottom: 110px; }
  .sec-panel.desk-all { display: block !important; }
  .fill-bar { padding: 14px 28px; }
  .fill-bar .btn { flex: 0 0 auto; min-width: 150px; }
  .fill-bar .sp { flex: 1; }

  .toast { bottom: 28px; }
  table.tbl { min-width: 0; }
}

@media (min-width: 1240px) {
  :root { --side-w: 262px; }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

/* Impresión: informe limpio en A4 */
@media print {
  .sidebar, .bottom-nav, .topbar, .fill-bar, .btn, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .tbl-wrap { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .page { padding: 0; max-width: none; }
  table.tbl { font-size: 11px; min-width: 0; }
  table.tbl th { background: #f0f0f0; color: #000; }
  a { color: #000; text-decoration: none; }
}

/* Utilidades de visibilidad por tamaño */
.solo-movil { display: block; }
.solo-pc    { display: none; }
@media (min-width: 900px) {
  .solo-movil { display: none; }
  .solo-pc    { display: block; }
}

/* ==================================================================
   Filtros plegables (en móvil ocupaban media pantalla antes de la lista)
   ================================================================== */
details.filtros-box { padding: 0; overflow: hidden; }
details.filtros-box > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; font-weight: 700; font-size: 15px;
}
details.filtros-box > summary::-webkit-details-marker { display: none; }
details.filtros-box > summary .rango { margin-left: auto; font-weight: 600; font-size: 13px; color: var(--ink-3); }
details.filtros-box > summary .caret { color: var(--ink-3); transition: transform .2s; }
details.filtros-box[open] > summary .caret { transform: rotate(180deg); }
details.filtros-box[open] > summary { border-bottom: 1px solid var(--line); }
details.filtros-box > .filtros-body { padding: 16px; }

/* ==================================================================
   Ajuste de tono: menos color, más jerarquía por tipografía
   ================================================================== */
/* Sombras más discretas: el borde ya separa las tarjetas */
:root { --sh-1: 0 1px 2px rgba(19,22,40,.04); --sh-2: 0 2px 8px rgba(19,22,40,.06); }
:root[data-theme="dark"] { --sh-1: 0 1px 2px rgba(0,0,0,.3); --sh-2: 0 3px 10px rgba(0,0,0,.35); }

/* Los recuadros de cifras van neutros; el acento se reserva a las acciones */
.stat .val { color: var(--ink); }
.badge { background: var(--line-2); color: var(--ink-2); font-weight: 600; }
.badge.ok   { background: transparent; color: var(--ok);   box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 35%, transparent); }
.badge.bad  { background: transparent; color: var(--bad);  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent); }
.badge.warn { background: transparent; color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 40%, transparent); }

/* Botón principal plano, sin degradado ni halo */
.btn-primary {
  background: var(--acc); border-color: var(--acc); color: #fff; box-shadow: none;
}
.btn-primary:hover { background: color-mix(in srgb, var(--acc) 88%, #000); box-shadow: none; }
.btn-soft { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-soft:hover { border-color: var(--acc); color: var(--acc); }

.brand-badge {
  background: var(--ink); box-shadow: none; border-radius: 9px;
  width: 30px; height: 30px; font-size: 15px;
}
.bn-item.center .bn-plus { background: var(--acc); box-shadow: none; border-radius: 13px; }
.side-avatar { background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); }

/* Cabecera de sección de lista: más discreta */
.list-head { color: var(--ink-3); font-weight: 700; letter-spacing: .04em; }

/* Estados vacíos sin emoji gigante */
.empty .ic { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px;
             border: 1px solid var(--line); border-radius: 12px; color: var(--ink-3); font-size: 0; }
.empty .ic svg { width: 20px; height: 20px; }

/* Botones de foto: contorno neutro */
.photo-btn { border-style: solid; border-color: var(--line); color: var(--ink-2); gap: 7px; }
.photo-btn svg { width: 17px; height: 17px; }
.photo-btn:hover { border-color: var(--acc); color: var(--acc); }

/* Icono pequeño dentro del hueco derecho de la tarjeta (contador de fotos) */
.list-item .end .bot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.list-item .end .bot svg { width: 13px; height: 13px; flex: 0 0 13px; }

/* Los dos botones de foto, uno al lado del otro (en el móvil se apilaban) */
.photo-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-btn { justify-content: center; padding: 10px 8px; font-size: 13.5px; }
@media (min-width: 560px) {
  .photo-btns { grid-template-columns: auto auto; justify-content: start; }
  .photo-btn { padding: 10px 16px; font-size: 14px; }
}

/* Usuario recién creado o con acceso regenerado: se destaca un momento */
.list-item.nuevo { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }

/* ==================================================================
   Resumen anual: gráfico de barras agrupadas
   ================================================================== */
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-scroll::-webkit-scrollbar { height: 6px; }
.chart-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.barchart { width: 100%; min-width: 560px; height: 240px; display: block; }
.barchart .bc-axis { stroke: var(--line-2); stroke-width: 1; }
.barchart .bc-lbl  { fill: var(--ink-3); font-size: 10px; font-weight: 600; font-family: inherit; }
.barchart rect { transition: opacity .15s; }
.barchart rect:hover { opacity: .8; }

.leyenda { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
