/* ===========================================================================
   Verificador de precios · El Castillo — hoja de estilos (CSS normal, sin Tailwind)
   =========================================================================== */

/* ───────────── Reinicio mínimo ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; }
input { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, p { margin: 0; }
a { color: inherit; }

/* ───────────── Iconos (Lucide) ─────────────
   Tamaño por defecto 20px; cada contexto lo ajusta si necesita otro (ver reglas "X svg" más abajo). */
svg.lucide { height: 1.25rem; width: 1.25rem; flex-shrink: 0; }

/* ───────────── Colores de marca ─────────────
   --brand-500/600/700 y --gold-500 no cambian de tono entre temas (ya tienen contraste de sobra).
   --brand-300/400 y --gold-200/300/400 sí se redefinen por tema más abajo: son los tonos claros
   pensados para fondo oscuro, y en claro se oscurecen para seguir leyéndose (p. ej. el título "precio"). */
:root {
  --brand-500: #e2262c;
  --brand-600: #c41c22;
  --brand-700: #9f161b;
  --gold-500: #c49a45;
}

/* ───────────── Tema ─────────────
   Por defecto CLARO: se invierte la escala de grises (slate) que usan todos los componentes.
   [data-theme="dark"] restaura la escala original. Luces y sombras son variables para que ambos temas
   tengan la misma iluminación (fuente de luz arriba) con la intensidad adecuada. */
:root {
  color-scheme: light;
  --page-bg: #f8fafc;
  --page-fg: #0f172a;
  --grid-line: rgb(15 23 42 / 0.045);
  --skeleton: rgb(226 232 240);
  --overlay: rgb(15 23 42 / 0.35);

  /* Luces (degradados radiales: se ven igual que un desenfoque pero no cuestan nada de rendimiento) */
  --glow-brand: rgb(226 38 44 / 0.06);
  --glow-gold: rgb(196 154 69 / 0.09);
  --glow-logo: rgb(226 38 44 / 0.15);
  --glow-sheet: rgb(226 38 44 / 0.06);
  --glow-price: rgb(226 38 44 / 0.07);

  /* Sombras suaves */
  --shadow-card: 0 10px 30px -18px rgb(15 23 42 / 0.14), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-field: inset 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-key: 0 1px 2px rgb(15 23 42 / 0.08), 0 1px 0 rgb(15 23 42 / 0.04);
  --shadow-tab: 0 1px 3px rgb(15 23 42 / 0.16), 0 1px 1px rgb(15 23 42 / 0.06);
  --shadow-sheet: 0 -8px 36px -14px rgb(15 23 42 / 0.18);
  --shadow-price: 0 10px 28px -20px rgb(226 38 44 / 0.35);
  --shadow-btn: 0 6px 16px -8px rgb(226 38 44 / 0.45), inset 0 1px 0 rgb(255 255 255 / 0.25);

  --slate-50: #020617;
  --slate-100: #0f172a;
  --slate-200: #1e293b;
  --slate-300: #334155;
  --slate-400: #475569;
  --slate-500: #64748b;
  --slate-600: #94a3b8;
  --slate-700: #cbd5e1;
  --slate-800: #e2e8f0;
  --slate-900: #ffffff;
  --slate-950: #f8fafc;

  /* Mismos tonos, en "R G B" (sin rgb()): permiten --slate-900-rgb) / alpha) sin la sintaxis rgb(from ...) */
  --slate-700-rgb: 203 213 225;
  --slate-800-rgb: 226 232 240;
  --slate-900-rgb: 255 255 255;
  --slate-950-rgb: 248 250 252;
  --brand-500-rgb: 226 38 44;
  --gold-400-rgb: 220 182 100;
  --gold-500-rgb: 196 154 69;

  /* Mismo rojo y dorado de marca, oscurecidos para seguir leyéndose sobre fondo claro */
  --brand-300: #d9272e;
  --brand-400: #c41c22;
  --gold-200: #7a5c14;
  --gold-300: #8f6b1a;
  --gold-400: #a67c1e;
  --emerald-300: #047857;

  /* ───────────── Superficies ─────────────
     En oscuro, slate-800/900/950 YA funcionan como "superficie elevada sobre el fondo" (son más claros
     que el fondo). En claro eso se invierte: slate-800/900 valen casi blanco, igual que la página, y un
     elemento "elevado" se volvería invisible. Por eso las superficies tienen sus propios tonos por tema,
     separados de la escala de texto/borde slate. */
  --surface-well: rgb(15 23 42 / 0.035);     /* hueco hundido: fondo de pestañas, campos de texto */
  --surface-card: rgb(255 255 255 / 0.75);   /* tarjeta principal, flotando sobre la página */
  --surface-card-border: rgb(15 23 42 / 0.08);
  --surface-raised: #ffffff;                 /* botón secundario, teclas, chips, filas de lista: sólido, con sombra */
  --surface-raised-border: rgb(15 23 42 / 0.1);
  --surface-raised-hover: #ffffff;
  --surface-raised-hover-border: rgb(15 23 42 / 0.16);
  --surface-pressed: #eef1f5;
  --surface-pill: #ffffff;                   /* píldora activa de las pestañas: la superficie más "alta" */
  --surface-pill-border: rgb(15 23 42 / 0.1);
  --surface-sheet: #ffffff;                  /* ventanas emergentes */
  --surface-price-inner: linear-gradient(to bottom, #ffffff, #fbfcfe);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #020617;
  --page-fg: #f1f5f9;
  --grid-line: rgb(148 163 184 / 0.06);
  --skeleton: rgb(51 65 85 / 0.5);
  --overlay: rgb(2 6 23 / 0.75);

  --glow-brand: rgb(196 28 34 / 0.2);
  --glow-gold: rgb(196 154 69 / 0.09);
  --glow-logo: rgb(226 38 44 / 0.34);
  --glow-sheet: rgb(196 28 34 / 0.22);
  --glow-price: rgb(226 38 44 / 0.18);

  --shadow-card: 0 30px 80px -30px rgb(0 0 0 / 0.9), inset 0 1px 0 rgb(255 255 255 / 0.04);
  --shadow-field: inset 0 2px 8px rgb(0 0 0 / 0.35);
  --shadow-key: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 4px 12px -6px rgb(0 0 0 / 0.6);
  --shadow-tab: 0 6px 20px -8px rgb(0 0 0 / 0.8), inset 0 1px 0 rgb(255 255 255 / 0.06);
  --shadow-sheet: 0 -20px 80px -20px rgb(0 0 0 / 0.9);
  --shadow-price: 0 20px 50px -28px rgb(226 38 44 / 0.55);
  --shadow-btn: 0 8px 24px -8px rgb(226 38 44 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.18);

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  --slate-700-rgb: 51 65 85;
  --slate-800-rgb: 30 41 59;
  --slate-900-rgb: 15 23 42;
  --slate-950-rgb: 2 6 23;
  --brand-500-rgb: 226 38 44;
  --gold-400-rgb: 220 182 100;
  --gold-500-rgb: 196 154 69;

  /* Tonos claros, pensados para fondo oscuro (valores originales de marca) */
  --brand-300: #fca5a5;
  --brand-400: #f2575b;
  --gold-200: #f6e3b0;
  --gold-300: #ecd08a;
  --gold-400: #dcb664;
  --emerald-300: #6ee7b7;

  /* En oscuro, la escala slate ya da el contraste correcto: las superficies reutilizan esos mismos tonos. */
  --surface-well: rgb(2 6 23 / 0.7);
  --surface-card: rgb(15 23 42 / 0.6);
  --surface-card-border: rgb(30 41 59 / 0.8);
  --surface-raised: rgb(15 23 42 / 0.7);
  --surface-raised-border: #1e293b;
  --surface-raised-hover: rgb(30 41 59 / 0.8);
  --surface-raised-hover-border: #334155;
  --surface-pressed: #334155;
  --surface-pill: linear-gradient(to bottom, #1e293b, #0f172a);
  --surface-pill-border: rgb(51 65 85 / 0.8);
  --surface-sheet: rgb(15 23 42 / 0.95);
  --surface-price-inner: linear-gradient(to bottom, #0f172a, #020617);
}

html, body {
  background-color: var(--page-bg);
  color: var(--page-fg);
  min-height: 100dvh;
}

body {
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "ss01", "cv11";
}

.mono { font-family: "Geist Mono", ui-monospace, monospace; }

::selection { background: rgb(226 38 44 / 0.35); }

button { touch-action: manipulation; cursor: pointer; }
button:disabled { pointer-events: none; opacity: 0.4; }

.scrollbar-thin { scrollbar-width: thin; scrollbar-color: var(--slate-700) transparent; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ───────────── Fondo de la página ───────────── */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background-color: var(--slate-950);
  pointer-events: none;
}
.backdrop .grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 55% at 50% 0%, black 30%, transparent 100%);
}
.backdrop .glow-top {
  position: absolute;
  top: -11rem;
  left: 50%;
  height: 480px;
  width: 760px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow-brand), transparent);
}
.backdrop .glow-bottom {
  position: absolute;
  bottom: -13rem;
  left: 50%;
  height: 440px;
  width: 700px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow-gold), transparent);
}
.backdrop .top-line {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgb(226 38 44 / 0.4), transparent);
}

/* ───────────── Estructura principal ───────────── */
.app-main {
  margin-inline: auto;
  display: flex;
  height: 100dvh;
  width: 100%;
  max-width: 28rem;
  flex-direction: column;
  overflow: hidden;
  padding-inline: 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  padding-top: max(0.75rem, env(safe-area-inset-top));
}
@media (min-width: 640px) {
  .app-main { max-width: 32rem; }
}

.hero {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: clamp(0.75rem, 4vw, 1.25rem);
  padding-bottom: clamp(0.5rem, 1.8dvh, 1.1rem);
  text-align: left;
}

.logo {
  position: relative;
  aspect-ratio: 13 / 10;
  height: clamp(4.25rem, 11.5dvh, 6.25rem);
  flex-shrink: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
  border-radius: 0.75rem;
  outline: none;
}
.logo:focus-visible { box-shadow: 0 0 0 2px rgb(226 38 44 / 0.5); }
.logo .glow {
  position: absolute;
  inset: -1.5rem;
  background: radial-gradient(closest-side, var(--glow-logo), transparent);
}
.logo img {
  position: relative;
  height: 100%;
  width: 100%;
  object-fit: contain;
}

.hero-text { min-width: 0; flex: 1; }
.hero-text h1 {
  font-size: clamp(1.55rem, min(4.4dvh, 8vw), 2.3rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--slate-50);
}
.hero-text h1 .accent {
  background: linear-gradient(to right, var(--brand-400), var(--brand-300), var(--gold-300));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.subtitle {
  margin-top: 0.375rem;
  min-height: 2.4em;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--slate-400);
}
@media (max-height: 700px) {
  .subtitle { display: none; }
}

.card {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  border-radius: 1.75rem;
  border: 1px solid var(--surface-card-border);
  background: var(--surface-card);
  padding: 0.75rem;
  box-shadow: var(--shadow-card);
}
.card-body { margin-top: 0.75rem; min-height: 0; flex: 1; }
.card-view { height: 100%; }

/* ───────────── Entradas / animaciones de aparición ───────────── */
.enter-hero { animation: enter-16 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.enter-card { animation: enter-24 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both; }
.rise { animation: rise 0.25s ease-out both; }
@keyframes enter-16 { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes enter-24 { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.anim-float { animation: float 7s ease-in-out infinite; }

@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.14) rotate(-3deg); } 100% { transform: scale(1); } }
.anim-pop { animation: pop 0.45s ease-out; }

/* Teclas: al pulsar se encogen con un pequeño rebote */
.tap {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.tap:active { transform: scale(0.93); }

/* Cambio de tema: fundido entre la "foto" anterior y la nueva (View Transitions, ver theme.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: ease;
}

/* Desenfoque del fondo (caro para la GPU): solo en teléfonos capaces */
.blur-overlay { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* Teléfonos de gama baja (ver el script de arranque en index.html): se quitan solo los efectos que más cuestan.
   El diseño, los colores y las animaciones de interacción se mantienen. */
:root[data-perf="low"] .blur-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
:root[data-perf="low"] .anim-float { animation: none; }

/* ───────────── Botones ───────────── */
.btn {
  display: inline-flex;
  user-select: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-weight: 600;
  border-radius: 1rem;
  transition: all 0.2s ease;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 4px rgb(226 38 44 / 0.25); }
.btn:disabled { pointer-events: none; opacity: 0.4; }
.btn:active { transform: scale(0.97); }
.btn svg.lucide { height: 1.15em; width: 1.15em; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(to bottom, var(--brand-500), var(--brand-600));
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { background: linear-gradient(to bottom, var(--brand-400), var(--brand-500)); }

.btn-secondary {
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  color: var(--slate-200);
  box-shadow: var(--shadow-key);
}
.btn-secondary:hover { border-color: var(--surface-raised-hover-border); background: var(--surface-raised-hover); }
.btn-secondary:active { background: var(--surface-pressed); }

.btn-lg { height: 3.5rem; border-radius: 1rem; padding-inline: 1.5rem; font-size: 1rem; }
.btn-lg.mt { margin-top: 0.25rem; }
.btn-lg.full { width: 100%; }
.btn-sm { height: 2.25rem; border-radius: 0.5rem; padding-inline: 0.75rem; font-size: 0.75rem; margin-top: 0.25rem; }
.btn-md { height: 2.75rem; border-radius: 0.75rem; padding-inline: 1rem; font-size: 0.875rem; }
.btn-md.full { width: 100%; }
.btn-compact {
  height: clamp(2.75rem, 6.5dvh, 3.5rem);
  min-width: 0;
  border-radius: 1rem;
  padding-inline: 0.75rem;
  font-size: 0.95rem;
}

/* ───────────── Pestañas (Código · Escanear · Nombre) ───────────── */
.tabs {
  position: relative;
  display: grid;
  flex-shrink: 0;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  border-radius: 1rem;
  border: 1px solid var(--surface-card-border);
  background: var(--surface-well);
  padding: 0.25rem;
}
.tabs .pill {
  position: absolute;
  pointer-events: none;
  border-radius: 0.75rem;
  border: 1px solid var(--surface-pill-border);
  background: var(--surface-pill);
  box-shadow: var(--shadow-tab);
}
.tab-btn {
  position: relative;
  display: flex;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition: color 0.2s ease;
  color: var(--slate-500);
}
.tab-btn:hover { color: var(--slate-300); }
.tab-btn.active { color: var(--slate-50); }
.tab-btn svg.lucide { position: relative; height: 1rem; width: 1rem; }
.tab-btn.active svg { color: var(--brand-400); }
.tab-btn span { position: relative; }

/* ───────────── Insignias y bloques de carga ───────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--slate-300);
}
.badge svg.lucide { height: 0.875rem; width: 0.875rem; }

.skeleton { border-radius: 0.5rem; background: var(--skeleton); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.skeleton.round { border-radius: 1rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ───────────── Barra de código / búsqueda ───────────── */
.field {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 1rem;
  border: 1px solid var(--surface-card-border);
  background: var(--surface-well);
  padding-left: 1rem;
  padding-right: 0.5rem;
  box-shadow: var(--shadow-field);
  transition: all 0.2s ease;
}
.field:focus-within { border-color: rgb(var(--brand-500-rgb) / 0.5); box-shadow: 0 0 0 4px rgb(226 38 44 / 0.1); }
.field svg.leading { color: var(--slate-500); transition: color 0.2s ease; }
.field:focus-within svg.leading { color: var(--brand-400); }
.field input {
  min-width: 0;
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  padding-inline: 0.75rem;
  outline: none;
  box-shadow: none;
  color: var(--slate-50);
}
.field input:focus,
.field input:focus-visible {
  outline: none;
  box-shadow: none;
}
.field input::placeholder { color: var(--slate-600); }
.field input::-webkit-search-decoration,
.field input::-webkit-search-cancel-button,
.field input::-webkit-search-results-button,
.field input::-webkit-search-results-decoration {
  display: none;
  appearance: none;
  -webkit-appearance: none;
}

.field-code { height: clamp(3rem, 7dvh, 4rem); flex-shrink: 0; }
.field-code input { font-family: "Geist Mono", ui-monospace, monospace; font-size: 1.5rem; font-weight: 500; letter-spacing: 0.04em; }
.field-code input::placeholder { font-family: "Geist", ui-sans-serif, sans-serif; font-size: 1rem; font-weight: 400; letter-spacing: normal; }

.field-search { height: 3rem; flex-shrink: 0; }
.field-search input { font-size: 1rem; }

.icon-btn {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  color: var(--slate-500);
  transition: all 0.2s ease;
}
.icon-btn:hover { background: var(--surface-pressed); color: var(--slate-200); }
.icon-btn.on { background: rgb(var(--brand-500-rgb) / 0.15); color: var(--brand-300); }

/* ───────────── Teclado numérico ───────────── */
.code-screen { display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 0.625rem; }
.keypad { display: grid; min-height: 0; flex: 1; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); gap: 0.5rem; }
.key {
  display: flex;
  height: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  border: 1px solid var(--slate-800);
  font-size: clamp(1.25rem, 3.4dvh, 1.75rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-key);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  user-select: none;
}
/* El encogido al pulsar lo hace code-entry.js con un resorte real (pointerdown/up, vía Web Animations API);
   esta regla :active solo es respaldo por teclado/accesibilidad, que no dispara eventos pointer. */
.key:active { transform: scale(0.93); }
.key-digit {
  border-color: var(--surface-raised-border);
  background: var(--surface-raised);
  color: var(--slate-100);
}
.key-digit:hover { border-color: var(--surface-raised-hover-border); background: var(--surface-raised-hover); }
.key-digit:active { background: var(--surface-pressed); }
.key-back {
  border-color: var(--surface-card-border);
  background: var(--surface-well);
  color: var(--slate-400);
}
.key-back:hover { background: var(--surface-pressed); color: var(--slate-100); }
.key-back:active { background: var(--surface-pressed); }
.key-dash { border-color: rgb(var(--gold-500-rgb) / 0.2); background: rgb(var(--gold-500-rgb) / 0.06); color: var(--gold-300); }
.key-dash:hover { background: rgb(var(--gold-500-rgb) / 0.1); }
.key-dash:active { background: rgb(var(--gold-500-rgb) / 0.15); }
.key-dash span { margin-top: -0.25rem; font-size: 1.875rem; }

.actions-row { display: grid; flex-shrink: 0; grid-template-columns: 1fr 2fr; gap: 0.625rem; }
.actions-row-2 { grid-template-columns: 1fr 1fr; }

/* ───────────── Búsqueda por nombre ───────────── */
.search-screen { display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 0.75rem; }
.results {
  position: relative;
  margin-inline: -0.25rem;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-inline: 0.25rem;
}
.results-empty { display: flex; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding-block: 0.5rem; text-align: center; }
.icon-tile {
  display: flex;
  height: 3rem;
  width: 3rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
}
.icon-tile svg.lucide { height: 1.5rem; width: 1.5rem; }
.results-empty p.title { font-weight: 500; color: var(--slate-200); }
.results-empty p.hint { margin-top: 0.25rem; font-size: 0.875rem; color: var(--slate-500); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.chip {
  border-radius: 9999px;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--slate-300);
  transition: all 0.2s ease;
}
.chip:hover { border-color: var(--surface-raised-hover-border); background: var(--surface-pressed); color: var(--slate-50); }

.loading-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.loading-row { display: flex; align-items: center; gap: 0.75rem; border-radius: 1rem; border: 1px solid var(--surface-card-border); background: var(--surface-well); padding: 0.75rem; }
.loading-row .skeleton.avatar { height: 2.5rem; width: 2.5rem; }
.loading-row .lines { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }

.state-msg { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding-block: 2.5rem; text-align: center; }
.state-msg p.title { font-weight: 500; color: var(--slate-200); }
.state-msg p.hint { font-size: 0.875rem; color: var(--slate-500); }

.count-label { margin-bottom: 0.5rem; padding-inline: 0.25rem; font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-500); }
.result-list { display: flex; flex-direction: column; gap: 0.5rem; }
.result-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  padding: 0.75rem;
  text-align: left;
  transition: all 0.2s ease;
}
.result-row:hover { border-color: var(--surface-raised-hover-border); background: var(--surface-pressed); }
.result-row:active { transform: scale(0.99); }
.result-row .tag-icon {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: linear-gradient(to bottom right, rgb(var(--brand-500-rgb) / 0.15), rgb(var(--gold-500-rgb) / 0.1));
  color: var(--brand-300);
  box-shadow: inset 0 0 0 1px rgb(var(--brand-500-rgb) / 0.2);
}
.result-row .tag-icon svg.lucide { height: 1.125rem; width: 1.125rem; }
.result-row .info { min-width: 0; flex: 1; }
.result-row .desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--slate-100);
}
.result-row .code { display: block; margin-top: 0.125rem; font-family: "Geist Mono", ui-monospace, monospace; font-size: 0.75rem; color: var(--slate-500); }
.result-row .chevron { color: var(--slate-600); transition: all 0.2s ease; }
.result-row:hover .chevron { transform: translateX(2px); color: var(--slate-300); }
mark.hl { border-radius: 0.25rem; background: rgb(var(--gold-400-rgb) / 0.15); padding-inline: 0.125rem; font-weight: 600; color: var(--gold-300); }

/* ───────────── Escáner de cámara ───────────── */
.scan-screen { display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 0.75rem; }
.viewport {
  position: relative;
  min-height: 0;
  width: 100%;
  flex: 1;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid var(--slate-800);
  background: #000;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.03);
}
.viewport video {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
  opacity: 0;
}
.viewport video.on { opacity: 1; }

.finder { pointer-events: none; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.finder-box {
  position: relative;
  height: 58%;
  width: 90%;
  border-radius: 1rem;
  box-shadow: 0 0 0 9999px rgb(2 6 23 / 0.55);
}
.finder-corner { position: absolute; height: 2rem; width: 2rem; border-color: var(--brand-400); }
.finder-corner.tl { left: 0; top: 0; border-left: 3px solid; border-top: 3px solid; border-top-left-radius: 1rem; }
.finder-corner.tr { right: 0; top: 0; border-right: 3px solid; border-top: 3px solid; border-top-right-radius: 1rem; }
.finder-corner.bl { bottom: 0; left: 0; border-bottom: 3px solid; border-left: 3px solid; border-bottom-left-radius: 1rem; }
.finder-corner.br { bottom: 0; right: 0; border-bottom: 3px solid; border-right: 3px solid; border-bottom-right-radius: 1rem; }
/* La línea roja está oculta; solo aparece al leer un código: baja rápido desde el centro y se desvanece */
.finder-laser { position: absolute; inset-inline: 0.75rem; inset-block: 0; transform: translateY(50%); opacity: 0; }
.finder-laser.sweep { animation: laser-sweep 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes laser-sweep {
  0% { transform: translateY(50%); opacity: 1; }
  70% { transform: translateY(97%); opacity: 1; }
  100% { transform: translateY(97%); opacity: 0; }
}
.finder-laser span { display: block; height: 2px; border-radius: 9999px; background: var(--brand-400); box-shadow: 0 0 14px 3px rgb(242 87 91 / 0.55); }
.finder-hint { position: absolute; bottom: 1.25rem; border-radius: 9999px; background: rgb(2 6 23 / 0.7); padding: 0.375rem 0.875rem; font-size: 0.75rem; font-weight: 500; color: #f1f5f9; }

.scan-debug {
  pointer-events: none;
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  z-index: 20;
  max-width: 85%;
  white-space: pre-wrap;
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 0.75);
  padding: 0.375rem;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.3;
  color: #a3e635;
}

.zoom-btn {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  background: rgb(2 6 23 / 0.7);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #f1f5f9;
  transition: transform 0.15s ease;
}
.zoom-btn:active { transform: scale(0.95); }
.zoom-btn svg.lucide { height: 0.875rem; width: 0.875rem; }

/* Panel del escáner: se ve en todos los estados menos con la cámara funcionando (activar, activando,
   permiso denegado, errores). Usa los colores normales de la tarjeta; el cuadro negro de video solo
   existe cuando hay cámara. */
.scan-pane[hidden] { display: none; }
.scan-pane {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 0.75rem;
  overflow-y: auto;
  border-radius: 1rem;
  border: 1px solid var(--surface-card-border);
  background: var(--surface-well);
  padding: 1.25rem;
  text-align: center;
}
.scan-pane > * { flex-shrink: 0; }
.scan-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-width: 20rem;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--slate-200);
}
.scan-steps li { counter-increment: step; display: flex; align-items: flex-start; gap: 0.625rem; }
.scan-steps li::before {
  content: counter(step);
  display: grid;
  flex-shrink: 0;
  place-items: center;
  height: 1.5rem;
  width: 1.5rem;
  border-radius: 9999px;
  background: var(--brand-500);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}
.step-icon {
  display: inline-grid;
  place-items: center;
  height: 1.6rem;
  width: 1.6rem;
  margin-inline: 0.1rem;
  vertical-align: middle;
  border-radius: 9999px;
  background: var(--slate-200);
  color: var(--page-bg);
}
.step-icon svg.lucide { height: 0.95rem; width: 0.95rem; }
.scan-alert { max-width: 20rem; border-radius: 0.75rem; background: rgb(var(--brand-500-rgb) / 0.12); padding: 0.5rem 0.75rem; font-size: 0.85rem; font-weight: 600; line-height: 1.35; color: var(--brand-400); }
.scan-link { padding: 0.5rem 0.75rem; font-size: 0.875rem; font-weight: 600; color: var(--slate-400); text-decoration: underline; }
.scan-pane .icon-tile.lg { height: 3.5rem; width: 3.5rem; border-radius: 1rem; }
.scan-pane .icon-tile.lg.accent { color: var(--brand-400); }
.scan-pane .icon-tile.lg svg.lucide { height: 1.75rem; width: 1.75rem; }
.scan-pane svg.lucide.spin { height: 2rem; width: 2rem; color: var(--brand-400); }
.scan-pane p.title { font-weight: 600; color: var(--slate-50); }
.scan-pane p.hint { max-width: 20rem; font-size: 0.875rem; line-height: 1.5; color: var(--slate-500); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ───────────── Ventanas emergentes (bottom sheets) ───────────── */
.sheet-root { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) {
  .sheet-root { align-items: center; padding: 1.5rem; }
}
.sheet-overlay { position: absolute; inset: 0; background: var(--overlay); }
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 28rem;
  user-select: none;
  overflow: hidden;
  border-top-left-radius: 2rem;
  border-top-right-radius: 2rem;
  border: 1px solid var(--surface-card-border);
  background: var(--surface-sheet);
  will-change: transform;
  box-shadow: var(--shadow-sheet);
}
@media (min-width: 640px) {
  .sheet-panel { border-radius: 2rem; }
}
.sheet-panel.history { display: flex; max-height: 85dvh; flex-direction: column; }
.sheet-glow { pointer-events: none; position: absolute; top: -6rem; left: 50%; height: 14rem; width: 28rem; transform: translateX(-50%); background: radial-gradient(closest-side, var(--glow-sheet), transparent); }
.sheet-grip-row { position: relative; display: flex; cursor: grab; justify-content: center; padding-bottom: 0.25rem; padding-top: 0.75rem; }
.sheet-grip-row:active { cursor: grabbing; }
.sheet-grip { height: 0.375rem; width: 3rem; border-radius: 9999px; background: var(--slate-700); }
.sheet-close-slot { position: absolute; right: 1rem; top: 1rem; z-index: 10; }
.sheet-close {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  color: var(--slate-400);
  transition: color 0.2s ease;
}
.sheet-close:hover { color: var(--slate-50); }
.sheet-close svg.lucide { height: 1rem; width: 1rem; }
.sheet-body { position: relative; padding-inline: 1.5rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); padding-top: 0.75rem; }

.sheet-header { position: relative; flex-shrink: 0; user-select: none; cursor: grab; padding-inline: 1.5rem; padding-bottom: 0.75rem; padding-top: 0.75rem; }
.sheet-header:active { cursor: grabbing; }
.sheet-header .grip-row { display: flex; justify-content: center; }
.sheet-header-row { margin-top: 0.75rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.sheet-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; color: var(--slate-50); }
.sheet-subtitle { margin-top: 0.125rem; font-size: 0.75rem; color: var(--slate-500); }

.history-list { position: relative; min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-inline: 1rem; padding-bottom: 0.75rem; }
.history-footer { position: relative; flex-shrink: 0; padding-inline: 1.5rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); padding-top: 0.75rem; }

.history-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--surface-raised-border);
  background: var(--surface-raised);
  padding: 0.75rem;
  text-align: left;
  transition: all 0.2s ease;
}
.history-row:hover { border-color: var(--surface-raised-hover-border); background: var(--surface-pressed); }
.history-row:active { background: var(--surface-pressed); }
.history-row .info { min-width: 0; flex: 1; }
.history-row .desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.875rem; font-weight: 500; line-height: 1.3; color: var(--slate-100); }
.history-row .meta { margin-top: 0.125rem; display: flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; color: var(--slate-500); }
.history-row .price { flex-shrink: 0; text-align: right; }
.history-row .price .bs { display: block; font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--slate-100); }
.history-row .price .usd { display: block; font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--gold-300); }

.history-empty { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding-inline: 1.5rem; padding-block: 3rem; text-align: center; }
.icon-tile.xl { height: 3.5rem; width: 3.5rem; }
.icon-tile.xl svg.lucide { height: 1.75rem; width: 1.75rem; }

.history-count {
  border-radius: 9999px;
  background: var(--surface-pressed);
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-300);
}

/* ───────────── Ficha del producto ───────────── */
/* Equivale a space-y-4 de Tailwind: separa los hijos en vertical sin volverlos flex
   (si fuera flex, los hijos inline-flex como .ps-badge-success se estirarían a todo el ancho). */
.ps-stack > * + * { margin-top: 1rem; }
.ps-loading-bar { height: 1.5rem; width: 80%; }
.ps-loading-bar.sm { height: 1rem; width: 50%; }
.ps-loading-block { height: 9rem; width: 100%; }
.ps-loading-block.btn-h { height: 3.5rem; }
.ps-row { display: flex; align-items: center; gap: 0.75rem; }
.ps-icon-tile {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: rgb(var(--brand-500-rgb) / 0.1);
  color: var(--brand-400);
  box-shadow: inset 0 0 0 1px rgb(var(--brand-500-rgb) / 0.2);
}
.ps-icon-tile svg.lucide.spin { height: 1.25rem; width: 1.25rem; }
.ps-row .term { font-family: "Geist Mono", ui-monospace, monospace; font-size: 0.75rem; color: var(--slate-500); }
.ps-row p.title { font-weight: 600; color: var(--slate-100); }

.ps-title { padding-right: 2rem; font-size: 1.25rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--slate-50); text-wrap: balance; }
.ps-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.price-card {
  border-radius: 1.4rem;
  background: linear-gradient(to bottom right, rgb(var(--brand-500-rgb) / 0.45), rgb(var(--slate-700-rgb) / 0.3), rgb(var(--gold-400-rgb) / 0.45));
  padding: 1px;
  box-shadow: var(--shadow-price);
}
.price-card-inner {
  position: relative;
  overflow: hidden;
  border-radius: calc(1.4rem - 1px);
  background: var(--surface-price-inner);
  padding: 1rem 1.25rem;
}
.price-glow { position: absolute; top: -4rem; left: 50%; height: 9rem; width: 18rem; transform: translateX(-50%); background: radial-gradient(closest-side, var(--glow-price), transparent); }
.price-label { position: relative; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.22em; color: var(--slate-400); }
.price-bs-row { position: relative; margin-top: 0.25rem; display: flex; align-items: baseline; gap: 0.5rem; }
.price-bs-row .unit { font-size: 1.25rem; font-weight: 600; color: var(--slate-400); }
.price-bs-row .amount { font-size: clamp(2.4rem, 12vw, 3.4rem); font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: var(--slate-50); font-variant-numeric: tabular-nums; }
.price-divider { position: relative; margin-block: 0.875rem; height: 1px; background: linear-gradient(to right, transparent, var(--slate-700), transparent); }
.price-ref-row { position: relative; display: flex; align-items: center; justify-content: space-between; }
.price-ref-tag { border-radius: 9999px; background: rgb(var(--gold-400-rgb) / 0.1); padding: 0.25rem 0.625rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; color: var(--gold-300); box-shadow: inset 0 0 0 1px rgb(var(--gold-400-rgb) / 0.25); }
.price-ref-value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gold-200); }


.msg-screen { padding-top: 0.5rem; text-align: center; }
.msg-icon-tile {
  margin-inline: auto;
  display: flex;
  height: 4rem;
  width: 4rem;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: rgb(var(--brand-500-rgb) / 0.1);
  color: var(--brand-400);
  box-shadow: inset 0 0 0 1px rgb(var(--brand-500-rgb) / 0.2);
}
.msg-icon-tile svg.lucide { height: 2rem; width: 2rem; }
.msg-title { margin-top: 1.5rem; font-size: 1.25rem; font-weight: 600; color: var(--slate-50); }
.msg-text { margin-top: 0.5rem; margin-inline: auto; max-width: 20rem; font-size: 0.875rem; line-height: 1.5; color: var(--slate-400); }
.msg-action { margin-top: 1.5rem; }
.msg-action.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.inline-code { color: var(--slate-200); }

/* ───────────── Botón de historial (bajo la tarjeta principal) ───────────── */
.history-btn {
  margin-top: 0.625rem;
  height: 2.75rem;
  width: 100%;
  flex-shrink: 0;
  justify-content: space-between;
  padding-inline: 1rem;
}
.history-btn .left { display: flex; align-items: center; gap: 0.5rem; }
.history-btn .left svg.lucide { color: var(--slate-400); }
.history-btn .right { display: flex; align-items: center; gap: 0.375rem; color: var(--slate-500); }
.history-btn .right svg.lucide { height: 1rem; width: 1rem; }

/* ───────────── Cartel imprimible ───────────── */
.poster-page { min-height: 100dvh; background: #f1f5f9; padding-inline: 1rem; padding-block: 2rem; }
.poster-toolbar { margin-inline: auto; margin-bottom: 1.5rem; display: flex; max-width: 36rem; align-items: center; justify-content: space-between; gap: 0.75rem; }
.poster-toolbar p { font-size: 0.875rem; color: #475569; }
.poster-toolbar .mono { font-family: "Geist Mono", ui-monospace, monospace; color: #0f172a; }

.poster-card {
  margin-inline: auto;
  display: flex;
  max-width: 36rem;
  flex-direction: column;
  align-items: center;
  border-radius: 2rem;
  background: #fff;
  padding: 2.5rem 2rem;
  text-align: center;
  color: #0f172a;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  box-shadow: 0 0 0 1px #e2e8f0, 0 20px 25px -5px rgb(0 0 0 / 0.1);
}
.poster-card img.logo-img { height: 8rem; width: auto; object-fit: contain; }
.poster-card h1 { margin-top: 1.5rem; font-size: 2.25rem; font-weight: 800; letter-spacing: -0.02em; }
.poster-card h1 .accent { color: #e2262c; }
.poster-card .tagline { margin-top: 0.5rem; font-size: 1.125rem; color: #475569; }

.poster-qr-frame { margin-top: 2rem; border-radius: 1.5rem; border: 4px solid #e2262c; padding: 1.25rem; }

.poster-steps { margin-top: 2rem; display: grid; width: 100%; gap: 0.75rem; text-align: left; }
@media (min-width: 640px) {
  .poster-steps { grid-template-columns: repeat(3, 1fr); }
}
.poster-step { display: flex; align-items: flex-start; gap: 0.75rem; border-radius: 1rem; background: #f8fafc; padding: 1rem; box-shadow: inset 0 0 0 1px #e2e8f0; }
@media (min-width: 640px) {
  .poster-step { flex-direction: column; }
}
.poster-step .num-icon { display: flex; height: 2.5rem; width: 2.5rem; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 0.75rem; background: #e2262c; color: #fff; }
.poster-step .num-icon svg.lucide { height: 1.25rem; width: 1.25rem; }
.poster-step .text { font-size: 0.875rem; font-weight: 500; line-height: 1.4; }
.poster-step .text .num { font-weight: 700; color: #c49a45; }

.poster-footer { margin-top: 2rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3em; color: #c49a45; }

@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .poster-page { background: #fff !important; padding: 0 !important; }
  .poster-toolbar { display: none !important; }
  .poster-card { max-width: none !important; border-radius: 0 !important; box-shadow: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
