@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --ink-bg: #0E1B2B;
  --ink-bg-raised: #142438;
  --paper: #FFFFFF;
  --paper-dim: #F2F2F2;
  --gold: #C9A24B;
  --mint: #4FAE8C;
  --coral: #D9634A;
  --ink-text: #0E1B2B;
  --paper-text: #F4EFE6;
  --paper-text-dim: rgba(244, 239, 230, 0.65);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink-bg);
  color: var(--paper-text);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Fraunces", serif; font-weight: 600; margin: 0; }

.mono { font-family: "IBM Plex Mono", monospace; }

a { color: inherit; }

/* ---------- Shell ---------- */

.shell { max-width: 720px; padding: 24px 20px 80px; }

/* ---------- App shell: sidebar + contenido ---------- */
/* Móvil: la sidebar es una barra horizontal arriba (como las tabs de antes).
   Escritorio (900px+): pasa a ser una columna fija a la izquierda. */

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.sidebar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid rgba(244,239,230,0.08);
  gap: 16px;
}
.sidebar-brand { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; flex-shrink: 0; }
.sidebar-brand .dot { color: var(--gold); }

.sidebar-nav { display: flex; gap: 4px; background: var(--ink-bg-raised); padding: 4px; border-radius: 999px; }
.nav-link {
  display: flex; align-items: center; gap: 6px; text-align: center; padding: 8px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; text-decoration: none; color: var(--paper-text-dim); white-space: nowrap;
}
.nav-link.active { background: var(--gold); color: var(--ink-bg); font-weight: 600; }
.nav-icon { font-size: 0.9rem; }

.icon-btn {
  background: none; border: 1px solid rgba(244,239,230,0.2); color: var(--paper-text-dim);
  padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.icon-btn:hover { color: var(--paper-text); border-color: rgba(244,239,230,0.4); }

/* "Descubre más" vive dentro de la sidebar. En móvil (sidebar en fila),
   flex-basis:100% lo obliga a bajar a su propia línea completa, debajo
   de marca+nav+salir, sin romper la barra superior. */
.sidebar-discover { flex-basis: 100%; min-width: 0; }

.content { flex: 1; min-width: 0; }

@media (min-width: 900px) {
  .app-shell { flex-direction: row; }

  .sidebar {
    flex-direction: column; align-items: stretch; justify-content: flex-start; flex-wrap: nowrap;
    width: 340px; flex-shrink: 0; height: 100vh; position: sticky; top: 0;
    border-bottom: none; border-right: 1px solid rgba(244,239,230,0.08);
    padding: 26px 18px; gap: 22px;
  }
  .sidebar-brand { font-size: 1.25rem; }
  .sidebar-nav { flex-direction: column; background: none; padding: 0; gap: 4px; }
  .nav-link { justify-content: flex-start; border-radius: 10px; padding: 10px 12px; }
  .nav-link.active { background: var(--ink-bg-raised); color: var(--gold); }

  /* flex:1 hace que "Descubre más" ocupe todo el hueco libre entre el nav
     y "Salir" (que así queda pinchado abajo sin necesitar margin-top:auto),
     con scroll propio si el contenido no cabe en la altura de pantalla. */
  .sidebar-discover {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  }
  .icon-btn { align-self: flex-start; margin-top: auto; }
}

/* ---------- Summary strip ---------- */

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.summary .stat {
  background: var(--ink-bg-raised); border-radius: 14px; padding: 16px 18px;
}
.summary .stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--paper-text-dim); }
.summary .stat .value { font-family: "IBM Plex Mono", monospace; font-size: 1.5rem; margin-top: 4px; }
.summary .stat.positive .value { color: var(--mint); }

/* ---------- Receipt card (elemento firma del sitio) ---------- */

.receipt {
  background: var(--paper); color: var(--ink-text); border-radius: 4px;
  padding: 20px 20px 16px; margin-bottom: 16px; position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  border-left: 5px solid var(--accent, var(--gold));
}
.receipt::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: 0;
  border-bottom: 1px dashed rgba(14,27,43,0.25);
}
.receipt-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.receipt-header-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.receipt-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.05rem; }
.receipt-sub { font-size: 0.78rem; color: rgba(14,27,43,0.6); margin-top: 2px; }
.receipt-fee { font-family: "IBM Plex Mono", monospace; font-size: 1rem; text-align: right; white-space: nowrap; }
.receipt-fee small { display: block; font-size: 0.65rem; color: rgba(14,27,43,0.5); font-weight: 400; }

.receipt-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pill {
  font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; font-weight: 500;
  border: 1px solid rgba(14,27,43,0.15);
}
.pill.mint { background: rgba(79,174,140,0.15); color: #2b6e54; border-color: rgba(79,174,140,0.3); }
.pill.coral { background: rgba(217,99,74,0.15); color: #a8442d; border-color: rgba(217,99,74,0.3); }
.pill.gold { background: rgba(201,162,75,0.18); color: #8a6b28; border-color: rgba(201,162,75,0.35); }

.receipt-toggle {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed rgba(14,27,43,0.2);
  font-size: 0.82rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  color: rgba(14,27,43,0.7);
}
.receipt-toggle span:last-child { display: inline-block; transition: transform 0.15s; }
.receipt-toggle.open span:last-child { transform: rotate(180deg); }

.benefits-list { margin-top: 12px; display: none; flex-direction: column; gap: 10px; }
.benefits-list.open { display: flex; }

.benefit-row {
  border-top: 1px dotted rgba(14,27,43,0.18); padding-top: 10px;
}
.benefit-row .b-title { font-size: 0.85rem; font-weight: 500; }
.benefit-row .b-value { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; color: rgba(14,27,43,0.6); }

.b-choice { display: flex; gap: 8px; margin-top: 8px; }
.b-choice button {
  flex: 1; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; padding: 7px 8px;
  border-radius: 6px; border: 1px solid rgba(14,27,43,0.2); background: transparent; cursor: pointer;
  color: rgba(14,27,43,0.75);
}
.b-choice button.extra.selected { background: var(--mint); border-color: var(--mint); color: #0d3628; font-weight: 600; }
.b-choice button.free.selected { background: rgba(14,27,43,0.1); border-color: rgba(14,27,43,0.3); font-weight: 600; }

.receipt-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.link-remove { font-size: 0.75rem; color: rgba(217,99,74,0.75); background: none; border: none; cursor: pointer; font-family: inherit; }
.link-remove:hover { color: var(--coral); }

/* ---------- Add product ---------- */

.add-box { background: var(--ink-bg-raised); border-radius: 14px; padding: 16px; margin-bottom: 28px; }
.add-box input {
  width: 100%; background: var(--ink-bg); border: 1px solid rgba(244,239,230,0.15); color: var(--paper-text);
  padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 0.9rem;
}
.add-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.add-result-row {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 10px;
  background: var(--ink-bg); border-radius: 8px; font-size: 0.85rem;
}
.add-result-row button {
  background: var(--gold); color: var(--ink-bg); border: none; padding: 6px 12px;
  border-radius: 6px; font-weight: 600; font-size: 0.78rem; cursor: pointer; font-family: inherit;
}
.add-result-row button:disabled { opacity: 0.5; cursor: default; }

/* ---------- Avatares con color por institución ---------- */

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; font-weight: 700; color: #0E1B2B; flex-shrink: 0;
}
.avatar.sm { width: 24px; height: 24px; font-size: 0.6rem; }
.avatar-stack { display: flex; margin-top: 12px; }
.avatar-stack .avatar { margin-right: -8px; border: 2px solid var(--ink-bg-raised); }

/* ---------- Barra de herramientas de la wallet (filtro por categoría) ---------- */

.wallet-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.type-pill {
  display: flex; align-items: center; gap: 6px; background: var(--ink-bg-raised);
  border: 1px solid rgba(244,239,230,0.15); color: var(--paper-text); border-radius: 999px;
  padding: 6px 12px; font-size: 0.78rem; font-family: inherit; cursor: pointer;
}
.type-pill.off { background: none; border-color: rgba(244,239,230,0.1); color: var(--paper-text-dim); opacity: 0.55; }
.type-pill:hover { border-color: rgba(244,239,230,0.35); }

/* ---------- Iconos (Lucide) ---------- */
/* lucide.createIcons() sustituye cada <i data-lucide="..."> por un <svg
   class="lucide lucide-...">; stroke="currentColor" por defecto, así que
   el color sigue al texto de alrededor sin tener que tocarlo aquí. */

svg.lucide { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }

.nav-icon { width: 16px; height: 16px; }
.qs-icon { width: 17px; height: 17px; opacity: 0.7; vertical-align: -4px; }
.g-icon { width: 17px; height: 17px; }
.g-chevron { width: 13px; height: 13px; }
.card-type-badge { width: 14px; height: 14px; }
.a-icon { width: 18px; height: 18px; }
.ag-chevron { width: 13px; height: 13px; }

.modal-close svg { width: 14px; height: 14px; }
.mb-entry-remove svg { width: 12px; height: 12px; vertical-align: -1px; }
.card-tap-hint svg { width: 12px; height: 12px; vertical-align: -1px; }
.type-pill svg { width: 13px; height: 13px; vertical-align: -2px; }

.section-header { display: flex; align-items: baseline; justify-content: space-between; margin: 30px 0 12px; }
.section-header h2 { font-size: 1.05rem; }
.section-header .hint { font-size: 0.78rem; color: var(--paper-text-dim); }

/* ---------- Paneles de grupo (agrupado por tipo, plegable) ---------- */

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.group-panel {
  background: var(--ink-bg-raised); border-radius: 14px; padding: 14px 16px; cursor: pointer;
  border: 1px solid rgba(244,239,230,0.06);
}
.group-panel .g-head { display: flex; align-items: center; gap: 8px; }
.group-panel .g-icon { font-size: 1.05rem; }
.group-panel .g-label { font-weight: 600; font-size: 0.88rem; flex: 1; }
.group-panel .g-count { font-size: 0.75rem; color: var(--paper-text-dim); }
.group-panel .g-chevron { color: var(--paper-text-dim); font-size: 0.75rem; transition: transform 0.15s; }
.group-panel.expanded .g-chevron { transform: rotate(180deg); }
.group-panel .g-sub { font-size: 0.75rem; color: var(--paper-text-dim); margin-top: 8px; }
.group-panel.expanded { grid-column: 1 / -1; cursor: default; }
.group-content { margin-top: 14px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Filas de "descubre más" (catálogo, solo añadir) ---------- */

.discover-row {
  display: flex; flex-direction: column; gap: 8px; background: var(--ink-bg); border-radius: 10px; padding: 10px 12px;
}
.discover-row .dr-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.discover-row .d-info { flex: 1; min-width: 0; }
.discover-row .d-name { font-size: 0.85rem; font-weight: 500; }
.discover-row .d-inst { font-size: 0.72rem; color: var(--paper-text-dim); }
.discover-row .dr-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 34px; }
.discover-row .d-fee { font-family: "IBM Plex Mono", monospace; font-size: 0.76rem; color: var(--paper-text-dim); white-space: nowrap; }
.discover-row button {
  background: var(--gold); color: var(--ink-bg); border: none; padding: 6px 12px; border-radius: 6px;
  font-weight: 600; font-size: 0.75rem; cursor: pointer; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.discover-row button:disabled { opacity: 0.5; cursor: default; }

.discover-flat { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Buscador (ahora solo filtra "Descubre más") ---------- */

.search-box input {
  width: 100%; background: var(--ink-bg-raised); border: 1px solid rgba(244,239,230,0.15); color: var(--paper-text);
  padding: 11px 12px; border-radius: 10px; font-family: inherit; font-size: 0.9rem; margin-bottom: 16px;
}

/* ---------- Layout de escritorio ---------- */

@media (min-width: 900px) {
  .shell.wide { max-width: 1500px; padding: 32px 40px 100px; }

  /* Una columna por categoría (--group-count lo calcula JS según cuántas
     categorías tiene realmente la wallet). El botón "Vista en columnas"
     alterna la clase .stacked para volver a la lista apilada de siempre. */
  .main-col .group-grid {
    display: grid;
    grid-template-columns: repeat(var(--group-count, 3), minmax(0, 1fr));
    gap: 18px;
    align-items: start;
  }
  .main-col .group-panel {
    max-width: 420px;    /* tope: con pocas categorías, la columna (1fr) puede
                             ser mucho más ancha que esto — sin el tope, la
                             tarjeta se estira y, por el aspect-ratio, también
                             se hace altísima */
    justify-self: center; /* si la columna sobra ancho, la card queda
                              centrada en vez de pegada a la izquierda */
  }
  .main-col .group-panel.expanded {
    grid-column: auto; /* anula el "ocupa toda la fila" de la regla base
                           (pensada para móvil de 1 columna) — aquí cada
                           categoría expandida debe quedarse en SU columna */
  }
}

/* ---------- Wallet items con forma de tarjeta física ---------- */

.wallet-card {
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.3);
  background: var(--paper);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.wallet-card:hover { box-shadow: 0 14px 34px rgba(0,0,0,0.4); }

.card-face {
  aspect-ratio: 1.586 / 1;
  padding: 18px 20px;
  position: relative;
  color: #fff;
  background-color: var(--accent, var(--gold));
  background-image:
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 38%),
    linear-gradient(0deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 42%),
    var(--card-photo, none);
  background-size: cover, cover, cover;
  background-position: center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.card-face::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 38%);
  pointer-events: none;
}
.card-face-row { display: flex; justify-content: space-between; align-items: flex-start; z-index: 1; }
.card-issuer {
  font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; letter-spacing: 0.09em; font-weight: 600;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 75%;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6), 0 0 10px rgba(0,0,0,0.35);
  background: rgba(0,0,0,0.32); padding: 4px 9px; border-radius: 5px; backdrop-filter: blur(2px);
}
.card-type-badge {
  font-size: 0.95rem; opacity: 0.95; z-index: 1;
  background: rgba(0,0,0,0.32); padding: 4px 8px; border-radius: 5px; backdrop-filter: blur(2px);
}
.card-name {
  font-family: "Fraunces", serif; font-weight: 600; font-size: 1rem; z-index: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.65), 0 0 12px rgba(0,0,0,0.4);
}

.card-panel { padding: 16px 20px 16px; color: var(--ink-text); }
.card-panel-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-panel-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1rem; }
.card-panel-sub { font-size: 0.76rem; color: rgba(14,27,43,0.6); margin-top: 2px; }
.card-panel-fee { font-family: "IBM Plex Mono", monospace; font-size: 0.95rem; text-align: right; white-space: nowrap; }
.card-panel-fee small { display: block; font-size: 0.63rem; color: rgba(14,27,43,0.5); font-weight: 400; }
.card-tap-hint { margin-top: 12px; font-size: 0.72rem; color: rgba(14,27,43,0.42); }

/* ---------- Modal (se abre al tocar una tarjeta) ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal-panel {
  background: var(--paper); color: var(--ink-text); border-radius: 18px;
  max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; position: relative;
  padding: 26px 24px 22px; box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; background: rgba(14,27,43,0.08); border: none;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 0.9rem; color: rgba(14,27,43,0.6);
}
.modal-close:hover { background: rgba(14,27,43,0.15); }

.modal-header { padding-right: 30px; }
.modal-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.2rem; }
.modal-sub { font-size: 0.82rem; color: rgba(14,27,43,0.6); margin-top: 2px; }

.modal-fee-row {
  display: flex; justify-content: space-between; align-items: center; margin-top: 16px;
  padding: 12px 14px; background: rgba(14,27,43,0.05); border-radius: 10px; font-size: 0.85rem;
}
.modal-fee-amount { font-family: "IBM Plex Mono", monospace; font-size: 1.05rem; }
.modal-fee-amount.waived { text-decoration: line-through; opacity: 0.5; font-size: 0.85rem; }
.modal-fee-waived-note { display: flex; align-items: center; gap: 8px; font-family: "IBM Plex Mono", monospace; font-size: 1.05rem; color: #2b6e54; }

.fee-toggle { display: flex; align-items: flex-start; gap: 9px; margin-top: 12px; font-size: 0.8rem; cursor: pointer; color: rgba(14,27,43,0.75); }
.fee-toggle input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--mint); cursor: pointer; flex-shrink: 0; }

.modal-benefits { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-benefit { border-top: 1px dashed rgba(14,27,43,0.18); padding-top: 12px; }
.modal-benefit .mb-title { font-size: 0.88rem; font-weight: 600; }
.mb-total { font-size: 0.78rem; color: #2b6e54; font-weight: 600; margin-top: 3px; }

.mb-input-row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.mb-input-row input[type="number"] {
  flex: 1; min-width: 0; background: #fff; border: 1px solid rgba(14,27,43,0.2); border-radius: 8px; padding: 8px 10px;
  font-family: "IBM Plex Mono", monospace; font-size: 0.88rem; color: var(--ink-text);
}
.mb-add-btn {
  background: var(--gold); color: var(--ink-bg); border: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: 0.8rem; cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.mb-add-btn:disabled { opacity: 0.5; cursor: default; }

.mb-entries { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.mb-entry {
  display: flex; align-items: center; gap: 8px; font-size: 0.76rem; color: rgba(14,27,43,0.6);
  padding: 4px 2px;
}
.mb-entry .mb-entry-date { flex-shrink: 0; }
.mb-entry .mb-entry-amount { font-family: "IBM Plex Mono", monospace; color: rgba(14,27,43,0.8); }
.mb-entry-remove {
  margin-left: auto; background: none; border: none; cursor: pointer; color: rgba(217,99,74,0.6);
  font-size: 0.72rem; padding: 0 2px;
}
.mb-entry-remove:hover { color: var(--coral); }

.modal-footer { margin-top: 22px; padding-top: 14px; border-top: 1px dashed rgba(14,27,43,0.2); display: flex; justify-content: flex-end; }

/* ---------- Búsqueda rápida ("¿qué descuento necesitas hoy?") ---------- */

.quick-search {
  display: flex; align-items: center; gap: 10px; background: var(--ink-bg-raised);
  border: 1px solid rgba(244,239,230,0.12); border-radius: 14px; padding: 14px 18px;
  margin-bottom: 20px; cursor: pointer; transition: opacity 0.15s ease, transform 0.15s ease;
}
.quick-search:hover { border-color: rgba(244,239,230,0.28); }
.quick-search .qs-icon { font-size: 1rem; opacity: 0.7; }
.quick-search .qs-placeholder { color: var(--paper-text-dim); font-size: 0.92rem; flex: 1; }
.quick-search .qs-kbd {
  font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--paper-text-dim);
  border: 1px solid rgba(244,239,230,0.2); border-radius: 5px; padding: 2px 6px;
}
.quick-search.hidden { opacity: 0; transform: scale(0.97); pointer-events: none; }

.search-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: none; align-items: flex-start; justify-content: center; z-index: 110; padding: 10vh 20px 20px;
}
.search-modal-backdrop.open { display: flex; }

.search-modal-panel {
  background: var(--paper); color: var(--ink-text); border-radius: 18px; width: 100%; max-width: 560px;
  max-height: 72vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 30px 70px rgba(0,0,0,0.55);
  opacity: 0; transform: scale(0.96) translateY(-6px); transition: opacity 0.15s ease, transform 0.15s ease;
}
.search-modal-backdrop.open .search-modal-panel { opacity: 1; transform: scale(1) translateY(0); }

.search-modal-input-row { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(14,27,43,0.1); flex-shrink: 0; }
.search-modal-input-row .qs-icon { font-size: 1rem; opacity: 0.5; }
.search-modal-input-row input {
  flex: 1; min-width: 0; border: none; background: transparent; font-family: inherit; font-size: 1rem;
  color: var(--ink-text); outline: none;
}
.search-modal-input-row .modal-close { position: static; background: rgba(14,27,43,0.08); flex-shrink: 0; }

#search-modal-results { overflow-y: auto; padding: 8px 10px 16px; }

.sr-empty { text-align: center; padding: 34px 20px; color: rgba(14,27,43,0.55); font-size: 0.86rem; line-height: 1.5; }

.sr-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 10px; border-radius: 10px; cursor: pointer; }
.sr-item:hover { background: rgba(14,27,43,0.05); }
.sr-item .sr-title { font-size: 0.88rem; font-weight: 600; }
.sr-item .sr-sub { font-size: 0.76rem; color: rgba(14,27,43,0.6); margin-top: 2px; }
.sr-item .sr-desc { font-size: 0.76rem; color: rgba(14,27,43,0.55); margin-top: 3px; line-height: 1.4; }
.sr-item .sr-value {
  font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; color: #2b6e54; white-space: nowrap;
  margin-left: auto; flex-shrink: 0;
}

/* ---------- Scrollbars personalizadas (finas, del color del tema) ---------- */

.sidebar-discover {
  scrollbar-width: thin;
  scrollbar-color: rgba(244,239,230,0.25) transparent;
}
.sidebar-discover::-webkit-scrollbar { width: 6px; }
.sidebar-discover::-webkit-scrollbar-track { background: transparent; }
.sidebar-discover::-webkit-scrollbar-thumb { background: rgba(244,239,230,0.25); border-radius: 999px; }
.sidebar-discover::-webkit-scrollbar-thumb:hover { background: rgba(244,239,230,0.4); }

.modal-panel, #search-modal-results {
  scrollbar-width: thin;
  scrollbar-color: rgba(14,27,43,0.25) transparent;
}
.modal-panel::-webkit-scrollbar, #search-modal-results::-webkit-scrollbar { width: 6px; }
.modal-panel::-webkit-scrollbar-track, #search-modal-results::-webkit-scrollbar-track { background: transparent; }
.modal-panel::-webkit-scrollbar-thumb, #search-modal-results::-webkit-scrollbar-thumb { background: rgba(14,27,43,0.2); border-radius: 999px; }
.modal-panel::-webkit-scrollbar-thumb:hover, #search-modal-results::-webkit-scrollbar-thumb:hover { background: rgba(14,27,43,0.35); }

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 40px 20px; color: var(--paper-text-dim); }
.empty h3 { color: var(--paper-text); margin-bottom: 8px; }

/* ---------- Alerts (promociones.html) ---------- */

.alert-card {
  background: var(--paper); color: var(--ink-text); border-radius: 4px; padding: 16px 18px;
  margin-bottom: 12px; display: flex; gap: 12px; align-items: flex-start;
  border-left: 4px solid var(--gold);
}
.alert-card.coral { border-left-color: var(--coral); }
.alert-card.mint { border-left-color: var(--mint); }
.alert-card .a-icon { font-size: 1.2rem; line-height: 1; }
.alert-card .a-title { font-weight: 600; font-size: 0.9rem; }
.alert-card .a-sub { font-size: 0.78rem; color: rgba(14,27,43,0.65); margin-top: 2px; }
.alert-card .a-days { font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; margin-left: auto; white-space: nowrap; }
.alert-card .btn-add-inline { margin-left: auto; align-self: center; }

/* ---------- Tarjetas agrupadas por producto (Promociones) ---------- */
/* En vez de una card por cada beneficio suelto (ruido visual si un
   producto tiene varias novedades a la vez), se agrupa: una card por
   producto, colapsada por defecto, con el detalle desplegable. */

.alert-group {
  background: var(--paper); color: var(--ink-text); border-radius: 4px;
  margin-bottom: 10px; border-left: 4px solid var(--gold); overflow: hidden;
}
.alert-group.mint { border-left-color: var(--mint); }
.alert-group.coral { border-left-color: var(--coral); }

.ag-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; }
.ag-head .a-icon { font-size: 1.05rem; flex-shrink: 0; }
.ag-info { flex: 1; min-width: 0; }
.ag-info .a-title { font-weight: 600; font-size: 0.88rem; }
.ag-info .a-sub { font-size: 0.76rem; color: rgba(14,27,43,0.6); margin-top: 2px; }
.ag-chevron { color: rgba(14,27,43,0.4); font-size: 0.72rem; transition: transform 0.15s; flex-shrink: 0; }
.ag-head.open .ag-chevron { transform: rotate(180deg); }

.ag-detail { display: none; flex-direction: column; padding: 0 16px 13px; gap: 5px; }
.ag-detail.open { display: flex; }
.ag-detail-row {
  display: flex; justify-content: space-between; gap: 10px; font-size: 0.79rem;
  padding-top: 7px; border-top: 1px dotted rgba(14,27,43,0.15); color: rgba(14,27,43,0.72);
}
.ag-detail-row .ag-detail-days { color: rgba(14,27,43,0.45); font-size: 0.71rem; flex-shrink: 0; white-space: nowrap; }

.section-label {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--paper-text-dim);
  margin: 24px 0 12px;
}
.section-label:first-child { margin-top: 0; }

.btn-add-inline {
  background: var(--gold); color: var(--ink-bg); border: none; padding: 6px 12px; border-radius: 6px;
  font-weight: 600; font-size: 0.75rem; cursor: pointer; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.btn-add-inline:disabled { opacity: 0.55; cursor: default; }

.promo-layout { display: block; }
.promo-col-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.promo-col-sub { font-size: 0.78rem; color: var(--paper-text-dim); margin-bottom: 4px; }

@media (min-width: 900px) {
  .shell.split { max-width: 1320px; padding: 32px 40px 100px; }
  .promo-layout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; align-items: start; }
}

/* ---------- Auth pages ---------- */

.auth-shell { max-width: 380px; margin: 0 auto; padding: 60px 20px; }
.auth-shell h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-shell .sub { color: var(--paper-text-dim); font-size: 0.88rem; margin-bottom: 28px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; margin-bottom: 6px; color: var(--paper-text-dim); }
.field input {
  width: 100%; background: var(--ink-bg-raised); border: 1px solid rgba(244,239,230,0.15); color: var(--paper-text);
  padding: 11px 12px; border-radius: 8px; font-family: inherit; font-size: 0.92rem;
}
.field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn-primary {
  width: 100%; background: var(--gold); color: var(--ink-bg); border: none; padding: 12px;
  border-radius: 8px; font-weight: 600; font-size: 0.92rem; cursor: pointer; margin-top: 6px; font-family: inherit;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.form-error {
  background: rgba(217,99,74,0.15); border: 1px solid rgba(217,99,74,0.4); color: #ff9b82;
  padding: 10px 12px; border-radius: 8px; font-size: 0.82rem; margin-bottom: 14px; display: none;
}
.form-error.visible { display: block; }

.form-success {
  background: rgba(79,174,140,0.15); border: 1px solid rgba(79,174,140,0.4); color: #7fd9b9;
  padding: 10px 12px; border-radius: 8px; font-size: 0.82rem; margin-bottom: 14px; display: none;
}
.form-success.visible { display: block; }

/* ---------- Ajustes ---------- */

.settings-section {
  background: var(--ink-bg-raised); border-radius: 14px; padding: 24px; margin-bottom: 20px; max-width: 520px;
}
.settings-section h3 { font-size: 1rem; margin-bottom: 4px; }
.settings-sub { font-size: 0.82rem; color: var(--paper-text-dim); margin-bottom: 18px; }
.settings-section.danger { border: 1px solid rgba(217,99,74,0.3); }
.settings-section.danger h3 { color: var(--coral); }

.profile-row {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 0;
  border-top: 1px dashed rgba(244,239,230,0.1); font-size: 0.88rem;
}
.profile-row:first-child { border-top: none; }
.profile-row .label { color: var(--paper-text-dim); }

.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.settings-toggle-title { display: block; font-size: 0.9rem; font-weight: 500; }
.settings-toggle-desc { display: block; font-size: 0.78rem; color: var(--paper-text-dim); margin-top: 2px; }
.settings-toggle-row input { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; flex-shrink: 0; }

.switch-link { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--paper-text-dim); }
.switch-link a { color: var(--gold); text-decoration: none; font-weight: 500; }