@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=Figtree:wght@400;500;600&display=swap');

/* Paleta Imagy: principal #0a0a0a · secundario #004fff · resaltado #00d2fe · terciario #009bff */
:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-2: #1b1b1b;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .22);
  --ink: #f3f5f8;
  --muted: #9aa3b4;
  --blue: #004fff;
  --blue-3: #009bff;
  --cyan: #00d2fe;
  --grad: linear-gradient(135deg, #004fff 0%, #009bff 100%);
  --error: #ff7a7a;
  --warn: #ffc766;
  --ratio: 9 / 16;
  --rn: 0.5625;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Figtree', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
::selection { background: var(--cyan); color: #0a0a0a; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
a { color: var(--cyan); }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px 32px; }

/* ---------- Barra superior ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0; margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand-name { font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.badge-pro {
  margin-left: 2px; padding: 1px 8px; font-size: 12px; font-weight: 600; color: #0a0a0a;
  background: var(--cyan); border-radius: 99px;
}
.topbar-links { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar-links a { color: var(--muted); text-decoration: none; }
.topbar-links a:hover { color: var(--ink); }
.topbar-user { color: var(--muted); font-size: 14px; }

/* ---------- Pestañas (app PRO) ---------- */

.tabs { display: flex; gap: 4px; margin: -8px 0 28px; overflow-x: auto; }
.tab {
  padding: 9px 16px; font-weight: 600; font-size: 14.5px; color: var(--muted);
  text-decoration: none; border-radius: 99px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: #0a0a0a; background: var(--cyan); }

/* ---------- Encabezados ---------- */

.header { margin-bottom: 28px; }
.header h1, .page-title {
  margin: 0; max-width: 680px;
  font-family: 'Bricolage Grotesque', 'Figtree', sans-serif;
  font-weight: 700; font-size: clamp(28px, 4.4vw, 46px);
  line-height: 1.06; letter-spacing: -.025em;
}
.page-title { font-size: clamp(24px, 3.2vw, 32px); margin-bottom: 6px; }
.lead { max-width: 520px; margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.section-title { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

/* ---------- Layout ---------- */

.grid { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 920px) {
  .grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); align-items: start; }
  .sticky { position: sticky; top: 24px; }
}

.card, .form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 24px 24px;
}
.card--tight { padding: 22px 24px; }
.stack > * + * { margin-top: 20px; }

.group { margin: 0; padding: 18px 0 0; min-width: 0; }
.group + .group { margin-top: 18px; border-top: 1px solid var(--line); }
.legend { display: block; margin: 0 0 10px; font-weight: 600; font-size: 15px; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.hint:empty { display: none; }
.opt { font-weight: 400; color: var(--muted); font-size: 13px; }

.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; border-top: 1px solid var(--line); margin-top: 18px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.row-2 .group { border-top: 0; margin-top: 0; }

/* ---------- Campos ---------- */

.input {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px;
}
.input::placeholder { color: #6c7587; }
select.input { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5l5 5 5-5' fill='none' stroke='%239aa3b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
textarea.input { resize: vertical; min-height: 120px; line-height: 1.5; }
.field + .field { margin-top: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.readonly { padding: 11px 13px; border: 1px dashed var(--line-strong); border-radius: 9px; color: var(--ink); background: transparent; word-break: break-all; }

details.more { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details.more[open] summary { margin-bottom: 12px; }

/* honeypot: invisible para personas */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Control segmentado (Sí / No) ---------- */

.seg { display: inline-flex; padding: 3px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 7px 22px; font-weight: 600; font-size: 14px; color: var(--muted); border-radius: 7px; cursor: pointer; }
.seg input:checked + label { color: #fff; background: var(--grad); }
.seg input:focus-visible + label { outline: 3px solid var(--cyan); outline-offset: 2px; }

.choices { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 560px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  display: block; height: 100%; padding: 12px 14px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px;
}
.choice label b { display: block; font-weight: 600; }
.choice label span { font-size: 13px; color: var(--muted); }
.choice input:checked + label { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.choice input:focus-visible + label { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  border: 0; border-radius: 10px; cursor: pointer;
}
.btn--block { display: flex; width: 100%; }

.btn--primary {
  margin-top: 22px; font-size: 16px; color: #fff; background-image: var(--grad);
  box-shadow: 0 10px 24px -10px rgba(0, 79, 255, .8);
  transition: filter .15s ease, transform .15s ease;
}
.btn--primary.btn--flat { margin-top: 0; }
.btn--primary:hover:not(:disabled) { filter: brightness(1.12) saturate(1.05); }
.btn--primary:active:not(:disabled) { transform: translateY(1px); }
.btn--primary:disabled { opacity: .55; cursor: not-allowed; }

.btn--cyan { color: #0a0a0a; background: var(--cyan); }
.btn--cyan:hover { filter: brightness(1.08); }

.btn--secondary { color: var(--ink); background: transparent; border: 1px solid var(--line-strong); }
.btn--secondary:hover { border-color: var(--cyan); color: var(--cyan); }
.btn--small { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn--danger { color: var(--error); background: transparent; border: 1px solid rgba(255, 122, 122, .4); }
.btn--danger:hover { background: rgba(255, 122, 122, .1); }

/* ---------- Mensajes ---------- */

.error-msg { margin: 14px 0 0; color: var(--error); font-size: 14px; font-weight: 500; }
.ok-msg { margin: 12px 0 0; color: var(--cyan); font-size: 14px; font-weight: 500; }
.notice {
  display: flex; gap: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.notice svg { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--cyan); }
.notice--warn { border-color: rgba(255, 199, 102, .45); }
.notice--warn svg { color: var(--warn); }
.notice b { font-weight: 600; }
.notice a { font-weight: 600; }

/* ---------- Selector de logo / modelo (crear) ---------- */

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px;
  font: inherit; text-align: center; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer;
}
.tile:hover { border-color: var(--ink); }
.tile.is-selected { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan); }
.tile.is-selected::after {
  content: ''; position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%230a0a0a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat,
    var(--cyan);
}
.tile-thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background: var(--surface-2); border-radius: 6px; color: var(--muted); }
.tile-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.picker--cover .tile-thumb img { object-fit: cover; padding: 0; }
.tile-thumb svg { width: 26px; height: 26px; }
.tile-cap { font-size: 12px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile--upload .tile-thumb { border: 1.5px dashed var(--line-strong); background: transparent; }
.tile.is-busy { opacity: .6; pointer-events: none; }

/* ---------- Marco de resultado (crear) ---------- */

.frame {
  --maxh: min(72vh, 640px);
  position: relative; width: min(100%, calc(var(--maxh) * var(--rn)));
  aspect-ratio: var(--ratio); margin-inline: auto; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  transition: width .25s ease;
}
.frame-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); }
.frame-placeholder { inset: 12px; border: 1.5px dashed var(--line-strong); border-radius: 10px; }
.frame-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.frame-loading-text { margin: 14px 0 0; }

.spinner { width: 34px; height: 34px; border: 3px solid rgba(0, 210, 254, .2); border-top-color: var(--cyan); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .frame, .btn--primary { transition: none; }
}

.after-frame { margin-top: 14px; }
.after-frame .btn { width: 100%; }

.refs { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); }
.ref { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ref-thumb { width: 44px; height: 44px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref--logo .ref-thumb img { object-fit: contain; }
.ref-text b { display: block; color: var(--ink); font-weight: 600; }

/* ---------- Tarjeta del prompt (público) ---------- */

.prompt-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.prompt-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.prompt-body { padding: 18px; max-height: 420px; overflow: auto; white-space: pre-wrap; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.prompt-empty { padding: 36px 24px; text-align: center; color: var(--muted); }
.prompt-empty .spinner { margin: 0 auto 14px; }
.prompt-foot { padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; }
.prompt-foot b { font-weight: 600; }
.prompt-foot ul { margin: 6px 0 0; padding-left: 18px; }
.prompt-foot li + li { margin-top: 3px; }

/* ---------- Panel PRO ---------- */

.pro-panel {
  margin-top: 20px; padding: 22px;
  border: 1px solid transparent; border-radius: 14px;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, #004fff, #00d2fe) border-box;
}
.pro-panel .pill { display: inline-block; padding: 2px 10px; font-size: 12.5px; font-weight: 600; color: #0a0a0a; background: var(--cyan); border-radius: 99px; }
.pro-panel h2 { margin: 10px 0 0; font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.pro-price { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 4px; flex-wrap: wrap; }
.pro-price strong { font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-size: 40px; line-height: 1; letter-spacing: -.03em; }
.pro-price span { color: var(--muted); font-size: 14px; }
.pro-list { margin: 14px 0 18px; padding: 0; list-style: none; font-size: 14.5px; }
.pro-list li { position: relative; padding-left: 26px; }
.pro-list li + li { margin-top: 7px; }
.pro-list li::before {
  content: ''; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%230a0a0a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat, var(--cyan);
}
.pro-links { margin: 12px 0 0; text-align: center; font-size: 13.5px; color: var(--muted); }

/* ---------- Biblioteca (Mi marca) ---------- */

.lib-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-count { color: var(--muted); font-size: 13px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.lib-card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.lib-thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.lib-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.lib-grid--cover .lib-thumb img { object-fit: cover; padding: 0; }
.lib-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.lib-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-warn { margin: 6px 0 0; font-size: 12px; color: var(--warn); line-height: 1.35; }
.lib-empty { margin: 16px 0 0; padding: 22px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: 10px; }
.icon-btn { flex: none; display: grid; place-items: center; width: 30px; height: 30px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.icon-btn:hover { color: var(--error); border-color: rgba(255, 122, 122, .5); }
.icon-btn svg { width: 16px; height: 16px; }
.reco { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.reco li + li { margin-top: 3px; }
.reco b { color: var(--ink); font-weight: 600; }

/* ---------- Login ---------- */

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.login-card .brand { margin-bottom: 20px; }
.login-card h1 { margin: 0 0 6px; font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-size: 26px; letter-spacing: -.02em; }
.login-card .sub { margin-bottom: 20px; }
.login-foot { margin: 18px 0 0; font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---------- Admin ---------- */

.table-wrap { overflow-x: auto; margin-top: 12px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { color: var(--muted); font-weight: 500; font-size: 13px; }
.status-on { color: var(--cyan); } .status-off { color: var(--error); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 300px; }
table.t td:last-child { white-space: normal; }
.cred-box { margin-top: 14px; padding: 14px; background: var(--surface-2); border: 1px solid var(--cyan); border-radius: 10px; font-size: 14px; }
.cred-box code { display: inline-block; margin-top: 4px; padding: 2px 8px; background: var(--bg); border-radius: 6px; font-size: 15px; user-select: all; }

/* ---------- Pie ---------- */

.credit { margin-top: 44px; text-align: center; }
.credit-link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; text-decoration: none; }
.credit-link:hover { color: var(--ink); }
.credit-link img { height: 18px; width: auto; }

/* ---------- Compra, confirmación y activación ---------- */

.buy-card { width: 100%; max-width: 480px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.buy-card .brand { margin-bottom: 18px; }
.buy-card h1 { margin: 0 0 4px; font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-size: 28px; line-height: 1.1; letter-spacing: -.02em; }
.buy-card .sub { margin-bottom: 14px; }
.buy-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 4px; }
.buy-price strong { font-family: 'Bricolage Grotesque', 'Figtree', sans-serif; font-size: 44px; line-height: 1; letter-spacing: -.03em; }
.buy-price span { color: var(--muted); font-size: 14px; }
.buy-card .pro-list { margin: 16px 0 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.check-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.check-row input { flex: none; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue-3); }
.fine { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }

.status-card { text-align: center; }
.status-card .brand { justify-content: center; }
.status-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 8px auto 16px; border-radius: 50%; color: #0a0a0a; background: var(--cyan); }
.status-icon svg { width: 28px; height: 28px; }
.status-icon--warn { background: var(--warn); }
.status-card .spinner { margin: 12px auto 18px; }
.status-card h1 { margin-bottom: 8px; }
.status-card p { margin: 0 0 14px; color: var(--muted); }
.status-card .btn { margin-top: 8px; }
.status-card .link-quiet { display: inline-block; margin-top: 14px; font-size: 13.5px; }
.status-card .fine { margin: 16px 0 0; }

/* ---------- Contador de piezas del mes ---------- */

.usage-note { margin-top: 14px; }
.usage-note p { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.usage-bar { height: 6px; overflow: hidden; background: var(--surface-2); border-radius: 99px; }
.usage-bar span { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .4s ease; }
.usage-note.is-low p { color: var(--warn); }
.usage-note.is-low .usage-bar span { background: var(--warn); }
.usage-note.is-out p { color: var(--error); }
.usage-note.is-out .usage-bar span { background: var(--error); }
@media (prefers-reduced-motion: reduce) { .usage-bar span { transition: none; } }

.sum-line { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.sum-line b { color: var(--ink); font-weight: 600; }
.limit-custom { color: var(--cyan); font-size: 12px; }
