:root {
  --bg: #fbfaf7;
  --card: #ffffff;
  --ink: #2b2a33;
  --muted: #8a8794;
  --line: #eeebe5;
  --brand: #3aa676;
  --brand-dark: #2a8a60;
  --brand-soft: #e8f6ef;
  --sun: #fff6dc;
  --promo: #e2603b;
  --promo-soft: #fff0ea;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 35, 60, .04), 0 6px 20px rgba(40, 35, 60, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: linear-gradient(180deg, #eef8f2 0, var(--bg) 320px);
  font: 16px/1.45 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand-dark); }
.wrap { max-width: 820px; margin: 0 auto; padding: 28px 16px 56px; }
.muted { color: var(--muted); }

/* Encabezado */
.top { text-align: center; }
.logo { font-size: 2.4rem; line-height: 1; }
.top h1 { margin: 8px 0 4px; font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.top h1 span { color: var(--brand); }
.tagline { margin: 0 0 14px; color: var(--muted); }
.status { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center;
  font-size: .85rem; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 14px; box-shadow: var(--shadow); }
.status form { display: inline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }
.btn-link { background: var(--brand-soft); border: 0; border-radius: 999px; padding: 5px 12px;
  color: var(--brand-dark); font: inherit; font-weight: 700; cursor: pointer; }
.btn-link:hover { background: #d6efe2; }
.busy { color: var(--promo); font-weight: 700; }
.busy .dot { background: var(--promo); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.error { color: var(--promo); font-size: .85rem; margin-top: 10px; }

/* Buscador */
.search { display: flex; gap: 8px; margin: 26px 0 10px; position: sticky; top: 0; z-index: 2;
  padding: 10px 0; background: transparent; }
.search-box { flex: 1; min-width: 0; position: relative; }
.search-box::before { content: "🔎"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.05rem; opacity: .7; }
.search input[type=search] { width: 100%; font: inherit; font-size: 1.1rem; padding: 15px 16px 15px 46px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); transition: border-color .15s; }
.search input[type=search]:focus { outline: none; border-color: var(--brand); }
.search input[type=submit] { font: inherit; font-weight: 800; padding: 0 22px; border: 0; border-radius: var(--radius);
  background: var(--brand); color: #fff; cursor: pointer; box-shadow: var(--shadow); }
.search input[type=submit]:hover { background: var(--brand-dark); }

  padding: 6px 14px; border-radius: 999px; font-size: .9rem; }
.empty { text-align: center; margin: 36px 0 8px; }
.empty .big { font-size: 2.6rem; }

.count { font-size: .85rem; margin: 4px 4px 14px; }

/* Producto */
.product { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.product-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.product h2 { font-size: 1.02rem; font-weight: 800; margin: 0; }
.meta { margin: 3px 0 0; font-size: .82rem; }
.ean { font-family: ui-monospace, monospace; font-size: .76rem; background: #f4f2ee; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.save { flex: none; background: var(--sun); color: #8a6200; font-size: .78rem; font-weight: 800;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

.rows { list-style: none; margin: 12px 0 0; padding: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px; }
.row + .row { margin-top: 4px; }
.row:nth-child(even) { background: #faf9f6; }
.row.best { background: var(--brand-soft); }
.store { display: flex; align-items: center; gap: 10px; min-width: 0; }
.badge { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: .8rem; color: #fff; }
.store-name { min-width: 0; }
.store-name strong { display: block; font-size: .95rem; }
.store-name small { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prices { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.final { font-size: 1.12rem; font-weight: 800; }
.best .final { color: var(--brand-dark); }
.was { display: block; font-size: .8rem; color: var(--muted); text-decoration: line-through; }
.promo { grid-column: 1 / -1; justify-self: start; margin-left: 44px; background: var(--promo-soft); color: var(--promo);
  font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 8px; }
.tag-best { display: inline-block; margin-left: 6px; background: var(--brand); color: #fff; font-size: .68rem;
  font-weight: 800; padding: 1px 7px; border-radius: 999px; vertical-align: middle; }

footer { margin-top: 36px; font-size: .8rem; text-align: center; }

@media (max-width: 560px) {
  .top h1 { font-size: 1.6rem; }
  .search input[type=submit] { display: none; }
  .product { padding: 14px; }
  .row { padding: 9px 8px; }
  .promo { margin-left: 0; }
  .product-head { flex-direction: column; gap: 6px; }
}

/* Supermercados indexados */
.stores { margin: 32px 0 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); }
.stores summary { cursor: pointer; font-weight: 800; list-style: none; }
.stores summary::-webkit-details-marker { display: none; }
.stores summary::after { content: "▾"; float: right; color: var(--muted); transition: transform .15s; }
.stores[open] summary::after { transform: rotate(180deg); }
.store-grid { list-style: none; padding: 0; margin: 14px 0 2px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.store-grid li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: #faf9f6; min-width: 0; }
.store-grid small { white-space: normal; }

/* /usage */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0 14px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stats strong { display: block; font-size: 1.6rem; color: var(--brand-dark); }
.stats span { font-size: .8rem; color: var(--muted); }
.top-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.top-list span { background: var(--brand-soft); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }
.top-list b { color: var(--brand-dark); margin-left: 4px; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
table.usage { width: 100%; border-collapse: collapse; font-size: .85rem; }
.usage th { text-align: left; color: var(--muted); font-weight: 700; font-size: .72rem; text-transform: uppercase; padding: 6px; }
.usage td { padding: 7px 6px; border-top: 1px solid var(--line); }
.usage .num { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, monospace; font-size: .78rem; }
