/* PORKY VIP — estilos del panel */
:root {
  --bg: #22091F;
  --surface: #2F0E2B;
  --surface-2: #3B1236;
  --line: #57214F;
  --text: #FFF3F7;
  --muted: #CFA9C4;
  --pig: #FF8DB5;
  --pig-strong: #FF5C93;
  --gold: #F4C24D;
  --gold-light: #FFE7A3;
  --gold-deep: #C98A12;
  --ok: #6EE7B0;
  --danger: #FF7A7A;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-key: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
  --radius: 14px;
  --bg-image: url("/media/background");
  --banner-image: url("/media/banner");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--gold); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }

/* Carga inicial */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot img { animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ─────────── Login ─────────── */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg) var(--bg-image) center / cover no-repeat;
}
.login-card {
  width: min(420px, 100%);
  text-align: center;
  padding: 36px 28px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 28px;
  backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px -30px rgba(10, 0, 8, .8);
}
.login-logo {
  margin: -96px auto 8px;
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .45));
  animation: drop-in .7s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes drop-in { from { transform: translateY(-30px) scale(.7); opacity: 0; } }
.wordmark {
  margin: 0;
  font: 800 clamp(40px, 11vw, 56px)/0.95 var(--font-display);
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}
.login-lead { margin: 14px 0 24px; color: var(--muted); }
.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 999px;
  background: #fff;
  color: #2a1a28;
  font-weight: 700;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-google:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -10px rgba(255, 141, 181, .7); }
.login-fine { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

/* ─────────── App ─────────── */
.app { min-height: 100vh; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand span { font: 800 20px/1 var(--font-display); letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.credits-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #3A1A02;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--pig); background: var(--surface-2); object-fit: cover; }
.usermenu-pop {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: min(280px, calc(100vw - 32px));
  display: grid; gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .7);
}
.usermenu-pop .btn { margin-top: 8px; }
.role-tag {
  justify-self: start;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--pig);
}

.hero {
  position: relative;
  background: var(--surface) var(--banner-image) right center / cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(34, 9, 31, .92) 0%, rgba(34, 9, 31, .65) 55%, rgba(34, 9, 31, 0) 100%);
}
.hero-inner { position: relative; max-width: 1080px; margin: 0 auto; padding: 36px 16px 30px; }
@media (max-width: 640px) {
  .hero::before { background: linear-gradient(90deg, rgba(34, 9, 31, .94) 0%, rgba(34, 9, 31, .78) 60%, rgba(34, 9, 31, .45) 100%); }
}
.hero h1 { margin: 0; font: 800 clamp(26px, 6vw, 38px)/1.05 var(--font-display); letter-spacing: -0.015em; }
.hero-text { margin: 6px 0 0; color: var(--muted); max-width: 46ch; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 18px 0 0; }
.hero-stats div { display: grid; }
.hero-stats dt { order: 2; font-size: 13px; color: var(--muted); }
.hero-stats dd { order: 1; margin: 0; font: 800 26px/1.1 var(--font-display); }
.hero-stats dd.is-active { color: var(--ok); }
.hero-stats dd.is-gold { color: var(--gold); }

.tabs {
  position: sticky; top: 61px; z-index: 10;
  display: flex; gap: 4px;
  max-width: 1080px; margin: 0 auto;
  padding: 10px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none;
  padding: 10px 14px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--pig); }

.view { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
.view h2 { margin: 0 0 4px; font: 700 24px/1.2 var(--font-display); letter-spacing: -0.01em; }
.view h3 { margin: 0 0 10px; font: 700 18px/1.25 var(--font-display); }
.section-lead { margin: 0 0 22px; color: var(--muted); max-width: 62ch; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}
.panel + .panel { margin-top: 18px; }
.grid-2 > .panel + .panel, .media-grid > .panel + .panel { margin-top: 0; }
.grid-2 { display: grid; gap: 18px; }
@media (min-width: 880px) { .grid-2 { grid-template-columns: 1.1fr .9fr; align-items: start; } }

/* ─────────── Formularios ─────────── */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span, .field-label { font-weight: 600; font-size: 15px; }
.hint { font-size: 13px; color: var(--muted); }
.input, select.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}
.input:focus { border-color: var(--pig); outline: none; box-shadow: 0 0 0 3px rgba(255, 141, 181, .25); }
.input.key-input { font-family: var(--font-key); text-transform: uppercase; letter-spacing: .04em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--pig); color: #3A0A24; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-gold { background: linear-gradient(180deg, var(--gold-light), var(--gold)); color: #3A1A02; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Duraciones: boletos para elegir */
.durations { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 6px 0 20px; }
@media (min-width: 560px) { .durations { grid-template-columns: repeat(4, 1fr); } }
.duration { position: relative; }
.duration input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.duration label {
  display: grid; gap: 2px;
  padding: 16px 14px 14px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.duration .d-num { font: 800 40px/1 var(--font-display); letter-spacing: -0.02em; }
.duration .d-unit { font-weight: 600; color: var(--muted); }
.duration .d-price { margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--pig); }
.duration label:hover { border-color: var(--pig); }
.duration input:checked + label {
  border-style: solid;
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(244, 194, 77, .22), rgba(244, 194, 77, .04));
  transform: translateY(-2px);
}
.duration input:checked + label .d-price { color: var(--gold); }
.duration input:focus-visible + label { outline: 3px solid var(--gold); outline-offset: 2px; }

.stepper { justify-self: start; display: inline-grid; grid-template-columns: 44px 72px 44px; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { height: 44px; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 700; cursor: pointer; }
.stepper button:hover { background: var(--line); }
.stepper input { height: 44px; border: 0; background: var(--bg); text-align: center; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px 0; margin: 4px 0 16px;
  border-top: 1px solid var(--line);
}
.summary strong { font: 800 22px/1 var(--font-display); color: var(--gold); }

/* ─────────── Boleto de key (la pieza estrella) ─────────── */
.tickets { display: grid; gap: 14px; }
.ticket {
  --cut: var(--surface);
  position: relative;
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 0;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--gold-light) 0%, var(--gold) 48%, #E3A52A 100%);
  color: #3A1A02;
  box-shadow: 0 14px 30px -18px rgba(244, 194, 77, .8);
  animation: ticket-in .45s cubic-bezier(.2, 1.2, .4, 1) both;
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; left: 52px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--cut);
}
.ticket::before { top: -8px; }
.ticket::after { bottom: -8px; }
.ticket-stub { display: grid; place-items: center; height: 100%; padding: 12px 0 12px 10px; }
.ticket-stub img { width: 40px; height: 40px; object-fit: contain; }
.ticket-body {
  display: grid; gap: 4px;
  padding: 14px 14px 14px 18px;
  border-left: 2px dashed rgba(58, 26, 2, .35);
  min-width: 0;
}
.ticket-code { font: 700 clamp(14px, 3.8vw, 18px)/1.2 var(--font-key); letter-spacing: .04em; word-break: break-all; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; font-weight: 600; opacity: .85; }
.ticket-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.ticket .btn-sm { background: rgba(58, 26, 2, .12); color: #3A1A02; }
.ticket .btn-sm:hover { background: rgba(58, 26, 2, .22); }
.ticket.is-dim { filter: grayscale(.85); opacity: .7; }
@keyframes ticket-in { from { transform: translateY(10px) rotate(-1.5deg); opacity: 0; } }
.tickets .ticket:nth-child(2) { animation-delay: .05s; }
.tickets .ticket:nth-child(3) { animation-delay: .1s; }
.tickets .ticket:nth-child(4) { animation-delay: .15s; }

/* ─────────── Listas ─────────── */
.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) { .toolbar { grid-template-columns: 1fr auto auto; align-items: center; } }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--pig); border-color: var(--pig); color: #3A0A24; }

.list { display: grid; }
.item {
  display: grid;
  gap: 8px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.item:first-child { border-top: 1px solid var(--line); }
@media (min-width: 760px) {
  .item.key-item { grid-template-columns: minmax(230px, 1.3fr) 1fr auto; align-items: center; }
  .item.user-item { grid-template-columns: minmax(220px, 1.2fr) 190px 1fr; align-items: center; }
}
.key-code {
  font: 700 15px/1.3 var(--font-key);
  letter-spacing: .03em;
  background: none; border: 0; padding: 0;
  text-align: left; cursor: pointer;
  color: var(--text);
  word-break: break-all;
}
.key-code:hover { color: var(--gold); }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-unused { color: var(--gold); background: rgba(244, 194, 77, .12); }
.pill-active { color: var(--ok); background: rgba(110, 231, 176, .12); }
.pill-expired { color: var(--muted); background: rgba(207, 169, 196, .1); }
.pill-revoked { color: var(--danger); background: rgba(255, 122, 122, .12); }
.days-badge { font-weight: 700; color: var(--text); }

.user-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-cell img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.user-cell .who { min-width: 0; }
.user-cell .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell .who span { display: block; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-badge { font-size: 12px; font-weight: 700; color: var(--gold); }
.credit-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.credit-box .input { width: 92px; min-height: 36px; padding: 6px 10px; }
.credit-value { font: 800 20px/1 var(--font-display); color: var(--gold); }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty img { width: 72px; margin: 0 auto 10px; opacity: .8; }
.load-more { margin-top: 16px; }

/* ─────────── Imágenes ─────────── */
.media-grid { display: grid; gap: 18px; }
@media (min-width: 720px) { .media-grid { grid-template-columns: 1fr 1fr; } }
.media-slot { display: grid; gap: 12px; }
.media-preview {
  display: grid; place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg) repeating-conic-gradient(#2a0c27 0 25%, #250a22 0 50%) 0 0 / 22px 22px;
  overflow: hidden;
}
.media-preview { position: relative; }
.media-preview img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 14px; object-fit: contain; }
.media-preview.is-cover img { padding: 0; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Ajustes */
.price-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .price-grid { grid-template-columns: repeat(4, 1fr); } }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; margin-bottom: 10px; }
.choice input { margin-top: 4px; accent-color: var(--pig); width: 18px; height: 18px; flex: none; }
.choice:has(input:checked) { border-color: var(--pig); background: rgba(255, 141, 181, .06); }
.choice small { display: block; color: var(--muted); }

/* API */
pre.code {
  margin: 8px 0 18px;
  padding: 14px 16px;
  background: #170614;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  font: 500 13.5px/1.6 var(--font-key);
  color: #FFDDEA;
}
.kv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv-table th, .kv-table td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv-table code { font-family: var(--font-key); color: var(--gold); }

/* Aviso flotante */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #2a0606; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
