/* Siempre en tema claro, también si el teléfono está en modo oscuro.
   Marca Farmamás: verde #6ABD46 (logo). Para botones y enlaces con texto
   blanco se usa un verde más oscuro del mismo tono, que sí se lee bien. */
:root {
  --logo: #6abd46;
  --brand: #3d7a1e;
  --brand-ink: #ffffff;
  --brand-soft: #edf7e7;
  --accent: #6abd46;
  --accent-ink: #10260a;
  --bg: #f5f8f4;
  --card: #ffffff;
  --ink: #1a2417;
  --muted: #5b6858;
  --line: #dde5d9;
  --low: #a85400;
  --out: #8f9a8c;
  --danger: #b3261e;
  --sale: #c2410c;
  --shadow: 0 1px 2px rgb(20 40 10 / .06), 0 4px 14px rgb(20 40 10 / .06);
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { line-height: 1.2; }

/* ---------- Encabezado ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 16px; height: 68px; }
.logo { display: flex; flex: none; }
.logo img { display: block; height: 36px; width: auto; }
.search { flex: 1; min-width: 0; position: relative; max-width: 620px; margin: 0 auto; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 44px; padding: 0 16px 0 42px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--bg);
}
.search input:focus { outline: none; border-color: var(--brand); background: var(--card); }
.cart-btn {
  position: relative; flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; display: grid; place-items: center;
}
.cart-btn svg { width: 24px; height: 24px; }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 2px var(--card);
  font-size: 13px; font-weight: 700; line-height: 22px; text-align: center;
}
.ratebar { background: var(--brand-soft); font-size: 13px; padding: 7px 0; }
.ratebar strong { color: var(--brand); }
.demo-note { background: #fff4d6; color: #5c4300; text-align: center; padding: 8px 16px; font-size: 13px; font-weight: 600; }
.notice { background: var(--card); border-bottom: 1px solid var(--line); text-align: center; padding: 8px 16px; font-size: 14px; }
@media (max-width: 640px) {
  .top-row { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 10px; }
  .logo { flex: 1; }
  .logo img { height: 32px; }
  .search { order: 3; flex-basis: 100%; }
  .top-cart { display: none; }
}

/* ---------- Banners ---------- */
.hero { padding-top: 16px; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 18px; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; scroll-snap-align: start; position: relative; overflow: hidden;
  min-height: 190px; padding: 28px 28px 30px; color: #fff; display: flex; align-items: center;
}
.slide-text { position: relative; z-index: 1; max-width: 560px; }
.slide h2 { margin: 0 0 8px; font-size: clamp(24px, 4.2vw, 40px); letter-spacing: -.01em; }
.slide p { margin: 0 0 16px; font-size: clamp(14px, 2vw, 18px); opacity: .95; max-width: 44ch; }
.slide-btn { display: inline-block; background: #fff; color: #1a2417; text-decoration: none; font-weight: 700; padding: 10px 20px; border-radius: 999px; }
.slide-mark { position: absolute; right: -40px; top: 50%; width: 240px; transform: translateY(-50%); opacity: .2; filter: brightness(0) invert(1); }
.tone-verde { background: linear-gradient(115deg, #2c5e15 0%, #3d7a1e 55%, #5aa337 100%); }
.tone-oscuro { background: linear-gradient(115deg, #142010 0%, #22361b 60%, #355a26 100%); }
.tone-naranja { background: linear-gradient(115deg, #9e3409 0%, #c2410c 55%, #e0701f 100%); }
.tone-azul { background: linear-gradient(115deg, #123a66 0%, #1d4e89 55%, #3270b8 100%); }
.dots { display: flex; justify-content: center; gap: 6px; padding-top: 10px; }
.dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 4px; background: var(--line); cursor: pointer; transition: width .2s; }
.dots button[aria-current="true"] { width: 22px; background: var(--brand); }
@media (min-width: 900px) { .slide { min-height: 240px; padding: 40px 48px; } .slide-mark { width: 320px; right: 40px; } }

/* ---------- Beneficios ---------- */
.perks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding-top: 16px; }
.perks div { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: 14px; line-height: 1.25; }
.perks svg { flex: none; width: 28px; height: 28px; color: var(--brand); }
@media (max-width: 800px) {
  .perks { grid-template-columns: repeat(2, 1fr); }
  .perks div { font-size: 13px; padding: 10px; }
  .perks svg { width: 24px; height: 24px; }
}

/* ---------- Bloques de la portada ---------- */
.block { padding-top: 28px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-head h2 { margin: 0; font-size: 22px; }
.block-head a { font-weight: 600; text-decoration: none; font-size: 15px; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
@media (max-width: 440px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 16px 6px 14px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--tile-bg); border: 1px solid transparent; transition: transform .15s;
}
.tile:hover { transform: translateY(-2px); }
.tile-ic { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--tile-ink); }
.tile-ic svg { width: 28px; height: 28px; }
.tile-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.tile-off { order: 3; background: var(--sale); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-top: -2px; }
.t0 { --tile-bg: #e8f5e0; --tile-ink: #3d7a1e; }
.t1 { --tile-bg: #e3f0fb; --tile-ink: #1d5f99; }
.t2 { --tile-bg: #fdeee3; --tile-ink: #b4520e; }
.t3 { --tile-bg: #f3e9fa; --tile-ink: #7a3fa0; }
.t4 { --tile-bg: #e2f5f3; --tile-ink: #137167; }
.t5 { --tile-bg: #fdf3d8; --tile-ink: #8a6400; }

.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 200px); gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.row .card { scroll-snap-align: start; }
@media (max-width: 640px) { .row { grid-auto-columns: calc(50% - 6px); gap: 10px; } }

.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0; margin: 0; }
.steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.steps li::before { content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; margin-bottom: 6px; }
.steps span { color: var(--muted); font-size: 14px; }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr; } }

/* ---------- Listado ---------- */
#list { padding-top: 16px; }
.list-head { display: flex; align-items: center; gap: 12px; }
.list-head h1 { margin: 0; font-size: 24px; }
.list-head .hint { margin: 2px 0 0; }
.back { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); text-decoration: none; font-size: 20px; color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; white-space: nowrap; font-size: 14px; text-decoration: none; color: var(--ink);
}
.chips a[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding: 8px 0 24px; }
@media (max-width: 440px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.more { text-align: center; padding-bottom: 32px; }
.more button { border: 1px solid var(--brand); color: var(--brand); background: none; border-radius: 999px; padding: 10px 22px; cursor: pointer; }

/* ---------- Tarjeta de producto ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.card .ph { position: relative; aspect-ratio: 1; background: #fff; display: grid; place-items: center; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card .ph.none { background: var(--brand-soft); }
.card .ph svg { width: 40%; height: 40%; color: var(--logo, #6abd46); opacity: .6; stroke-width: 1.4; }
.off { position: absolute; top: 8px; left: 8px; z-index: 1; background: var(--sale); color: #fff; font-weight: 800; font-size: 13px; padding: 3px 8px; border-radius: 6px; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card .cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card h3 {
  font-size: 14px; font-weight: 600; margin: 0; line-height: 1.3; overflow-wrap: anywhere; min-height: 2.6em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.price { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.price .was { font-size: 13px; color: var(--muted); text-decoration: line-through; }
.price .usd { font-size: 19px; font-weight: 800; }
.price .usd.sale { color: var(--sale); }
.price .bs { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.status { font-size: 12px; font-weight: 600; }
.status.low { color: var(--low); }
.status.out { color: var(--out); }
.buy > * { width: 100%; }
.add {
  margin-top: 8px; height: 40px; border: 0; border-radius: 10px; background: var(--brand); color: var(--brand-ink);
  font-weight: 700; cursor: pointer;
}
.add:disabled { background: var(--line); color: var(--muted); cursor: default; }
.qty { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; border: 1.5px solid var(--brand); border-radius: 10px; height: 40px; }
.qty button { width: 40px; height: 100%; border: 0; background: none; color: var(--brand); font-size: 20px; cursor: pointer; }
.qty span { font-weight: 700; }

/* ---------- Pie ---------- */
.foot { margin-top: 36px; border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 13px; padding: 24px 0 32px; }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.foot p { margin: 8px 0 0; }
.wa-link { display: inline-block; margin-top: 4px; font-weight: 700; text-decoration: none; }
@media (max-width: 640px) { .foot-grid { grid-template-columns: 1fr; } .foot { padding-bottom: 96px; } }

/* ---------- Navegación inferior (celular) ---------- */
.bottom-nav { display: none; }
@media (max-width: 640px) {
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
    font-size: 11px; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer;
  }
  .bottom-nav svg { width: 24px; height: 24px; }
  .bottom-nav [aria-current] { color: var(--brand); font-weight: 700; }
  .bottom-nav .badge { top: -2px; right: calc(50% - 26px); }
}

/* ---------- Carrito ---------- */
.drawer { position: fixed; inset: 0; z-index: 10; }
.drawer-bg { position: absolute; inset: 0; background: rgb(0 0 0 / .45); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--card); display: flex; flex-direction: column; overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.cart-items { padding: 4px 16px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line .n { font-size: 14px; font-weight: 600; }
.line .p { font-size: 14px; text-align: right; }
.line .qty { margin: 0; width: 120px; height: 34px; }
.line .rm { border: 0; background: none; color: var(--danger); font-size: 13px; cursor: pointer; justify-self: end; }
.checkout { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.checkout fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.checkout legend { font-weight: 600; padding: 0 4px; }
.checkout label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.checkout fieldset label { flex-direction: row; align-items: center; gap: 8px; }
.checkout input:not([type="radio"]), .checkout select, .checkout textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--bg); width: 100%;
}
.totals { background: var(--brand-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; }
.totals .saved { color: var(--sale); font-weight: 600; }
.totals .grand { font-size: 17px; font-weight: 700; margin-top: 4px; }
.primary { height: 48px; border: 0; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 16px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
