:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e4e6eb;
  --accent: #2563eb;
  --ok: #0f9d58;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #262b35;
    --accent: #5b8cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 20px 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 640px; margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.sesion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sesion .id {
  font-size: 13px;
  color: var(--muted);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sesion .btn { padding: 7px 12px; font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body { padding: 20px; }

.hero {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, var(--line), transparent);
}

.hero-fallback {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, rgba(37, 99, 235, .12), rgba(37, 99, 235, .02));
  font-size: 52px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .04em;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}

h2.nombre {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid currentColor;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }

.desc { margin: 0 0 20px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.cell { background: var(--card); padding: 12px 14px; }
.cell dt { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 3px; }
.cell dd { margin: 0; font-size: 15px; font-weight: 600; }

.notas {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--warn);
  background: rgba(217, 119, 6, .08);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}

.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }

.lista { list-style: none; margin: 0; padding: 0; }

.lista li + li { border-top: 1px solid var(--line); }

.lista a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  color: inherit;
  text-decoration: none;
}

.lista a:hover { background: rgba(127, 127, 127, .06); }
.lista .id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }
.foot a { color: var(--muted); }

.msg { text-align: center; padding: 40px 20px; }
.msg .big { font-size: 40px; margin-bottom: 8px; }
.msg h2 { margin: 0 0 8px; font-size: 20px; }
.msg p { color: var(--muted); margin: 0 0 18px; }

code.id-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(127, 127, 127, .14);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 13px;
}

/* --- generador --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.field input, .field select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.field textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 76px;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.dos-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: rgba(220, 38, 38, .08); border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.extra-fila {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.extra-fila button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 10px;
  width: 40px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.extra-fila button:hover { color: var(--bad); border-color: var(--bad); }

.foto-zona { display: flex; gap: 14px; align-items: flex-start; }

.foto-prev {
  width: 108px;
  height: 108px;
  flex: none;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--bg);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
}

.foto-prev img { width: 100%; height: 100%; object-fit: cover; }

.foto-botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.foto-botones .hint { margin-top: 0; flex-basis: 100%; }

.aviso {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-top: 14px;
}

.aviso.ok { background: rgba(15, 157, 88, .12); color: var(--ok); }
.aviso.error { background: rgba(220, 38, 38, .1); color: var(--bad); }

.lista .acciones-fila { display: flex; gap: 6px; }

.lista .mini {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.lista .mini:hover { color: var(--accent); border-color: var(--accent); }
.lista .mini.del:hover { color: var(--bad); border-color: var(--bad); }
.lista .fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.lista .fila .info { min-width: 0; }
.lista .fila .info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qr-box { display: grid; place-items: center; padding: 20px; background: #fff; border-radius: 10px; margin-top: 8px; }
.qr-box img, .qr-box canvas { max-width: 100%; height: auto; }
.url-out { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
