.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.price-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.price-card .name { font-weight: 600; font-size: 14.5px; }
.price-card .plaza { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.price-source { font-size: 13px; padding: 3px 7px; border-radius: 2px; white-space: nowrap; }
.price-source.propia { background: var(--accent-tint); color: var(--accent-strong); }
.price-source.externa { background: var(--surface-2); color: var(--text-muted); }
.price-value-row { display: flex; align-items: baseline; gap: 8px; }
.price-value { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.price-unit { font-size: 13px; color: var(--text-muted); }
.price-delta { font-size: 12.5px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.price-delta.up { color: var(--ok-fg); }
.price-delta.down { color: var(--crit-fg); }
.price-delta.flat { color: var(--text-muted); }
.price-trend { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price-sparkline { flex: 1 1 auto; min-width: 30px; width: 100%; height: 22px; color: var(--text-muted); }
.price-sparkline.up { color: var(--ok-fg); }
.price-sparkline.down { color: var(--crit-fg); }
.price-card-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--text-muted); }
.price-offer { font-size: 13px; background: var(--warn-tint); color: var(--warn-fg); padding: 3px 8px; border-radius: 2px; }
.price-source { border-radius: 6px; }
.price-offer { border-radius: 6px; padding: 2px 8px; }
.price-card[hidden] { display: none; }

/* ---------- Barra de filtros: botón + chips activos + contador ---------- */
.pf-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-open { font: inherit; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); cursor: pointer; }
.pf-open svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .pf-open:hover { border-color: var(--text-muted); } }
.pf-open .pf-n { background: var(--accent); color: var(--accent-on); font-size: 13px; border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
.pf-open .pf-n[hidden] { display: none; }
.pf-active { display: flex; gap: 6px; flex-wrap: wrap; }
.pf-tag { font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 12px; min-height: 34px; border: 0; border-radius: var(--r); background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; cursor: pointer; }
.pf-tag svg { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { .pf-tag:hover { background: var(--step-1); } }
.pf-clear { font: inherit; font-size: 14px; background: none; border: 0; color: var(--text-muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px 4px; }
.pf-count { margin-left: auto; font-size: 14px; color: var(--text-muted); }
.pf-legend { font-size: 14px; color: var(--text-muted); margin: 0; }

/* ---------- Panel de filtros: lateral en escritorio, hoja inferior en móvil ---------- */
.pf-dialog { border: 0; padding: 0; margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(400px, 100%); max-width: 100%; background: var(--surface); color: var(--text); box-shadow: -8px 0 32px rgba(28, 35, 32, .12); }
.pf-dialog::backdrop { background: rgba(28, 35, 32, .32); }
.pf-dialog[open] { display: flex; }
.pf-form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.pf-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.pf-head h2 { margin: 0; font-size: 19px; }
.pf-x { font: inherit; background: none; border: 0; width: 40px; height: 40px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; }
.pf-x svg { width: 20px; height: 20px; }
@media (hover: hover) and (pointer: fine) { .pf-x:hover { background: var(--surface-2); color: var(--text); } }
.pf-body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; display: flex; flex-direction: column; }
.pf-group { border: 0; margin: 0; padding: 16px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pf-group:last-child { border-bottom: 0; }
.pf-group legend, .pf-group > label { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
.pf-options { display: flex; flex-wrap: wrap; gap: 8px; clear: both; }
.pf-opt { position: relative; }
.pf-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pf-opt span { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--r); font-size: 15px; color: var(--text); background: var(--surface); }
.pf-opt input:checked + span { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.pf-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .pf-opt:hover span { border-color: var(--text-muted); } }
.pf-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; clear: both; }
.pf-selects label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-muted); }
.pf-selects select { font: inherit; font-size: 15px; padding: 9px 10px; min-height: 42px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); }
.pf-foot { display: flex; gap: 10px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); }
.pf-foot button { font: inherit; font-size: 15px; font-weight: 600; min-height: 46px; border-radius: var(--r); cursor: pointer; }
.pf-reset { flex: 0 0 auto; padding: 0 16px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); }
.pf-apply { flex: 1; background: var(--accent); border: 1px solid var(--accent); color: var(--accent-on); }
@media (hover: hover) and (pointer: fine) { .pf-apply:hover { background: var(--accent-strong); } }

@media (max-width: 640px) {
  .pf-dialog { margin: auto 0 0; width: 100%; height: auto; max-height: 88vh; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 32px rgba(28, 35, 32, .14); }
  .pf-count { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .pf-dialog[open] { animation: pf-in 220ms var(--ease-out); }
  @keyframes pf-in { from { transform: translateX(24px); opacity: 0; } }
  @media (max-width: 640px) { @keyframes pf-in { from { transform: translateY(32px); opacity: 0; } } }
}

/* ---------- Estrella de favorita (arriba a la derecha) ---------- */
.fav-form { margin: -6px -8px 0 0; flex-shrink: 0; }
.fav { width: 40px; height: 40px; border: 0; border-radius: var(--r); background: none; color: var(--line-strong); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.fav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; transition: transform 160ms var(--ease-out); }
.fav.on { color: var(--harvest); }
.fav.on svg { fill: currentColor; }
@media (hover: hover) and (pointer: fine) { .fav:hover { color: var(--harvest); background: var(--surface-2); } }
.fav:active svg { transform: scale(0.85); }
.price-card-foot .price-source { margin-right: 6px; }
.pf-note { font-size: 14px; color: var(--warn-fg); font-weight: 600; }
.pf-note:empty { display: none; }

/* ---------- Favoritas en el resumen ---------- */
.fav-block { display: flex; flex-direction: column; gap: 10px; }
.fav-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fav-block-head h2 { margin: 0; font-size: 17px; }
.fav-block-head a { font-size: 15px; font-weight: 600; color: var(--accent-strong); text-decoration: none; }
.fav-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px; }
.price-card.compact { padding: 12px 14px; gap: 6px; }
.price-card.compact .price-value { font-size: 20px; }
.price-card.compact .price-card-foot { border-top: 0; padding-top: 0; }
.fav-hint { margin: 0; font-size: 14px; color: var(--text-muted); }
.fav-empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 16px; color: var(--text-muted); font-size: 15px; }
.fav-empty a { color: var(--accent-strong); font-weight: 600; }
@media (max-width: 640px) {
  /* Móvil: las favoritas en una tira horizontal que se desliza con el dedo. */
  .fav-row { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 14px; gap: 10px; margin-inline: -14px; padding: 2px 14px 6px; scrollbar-width: none; }
  .fav-row::-webkit-scrollbar { display: none; }
  .fav-row .price-card { flex: 0 0 72%; scroll-snap-align: start; }
}

/* Fecha del boletín bajo el H1 de las páginas públicas de precio. */
.pc-fecha { margin: 0 0 6px; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--accent-tint); border-radius: 0 var(--r) var(--r) 0; font-size: 15px; color: var(--text); }
.pc-fecha + .pc-lead { margin-top: -20px; }

/* Resumen arriba: precio medio nacional y comparación con hace un año. */
.pc-resumen { margin: -8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 16px; color: var(--text); }
.pc-resumen li { padding-left: 16px; position: relative; }
.pc-resumen li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* Evolución anual: gráfica SVG del servidor, sin JS. */
.pc-nota-arriba { margin: -6px 0 14px; color: var(--text-muted); font-size: 15px; max-width: 70ch; }
.pc-graficas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; }
.pc-grafica { margin: 0; padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.pc-grafica figcaption { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.pc-grafica figcaption span { font-weight: 400; color: var(--text-muted); font-size: 13px; }
.pc-grafica svg { display: block; width: 100%; height: auto; overflow: visible; }
.pc-grafica .rejilla { stroke: var(--line); stroke-width: 1; }
.pc-grafica .eje { fill: var(--text-muted); font-size: 16px; font-family: var(--font-body); }
.pc-grafica .media { fill: none; stroke: var(--step-2); stroke-width: 2; stroke-dasharray: 5 4; }
.pc-grafica .anterior { fill: none; stroke: var(--harvest); stroke-width: 2; }
.pc-grafica .actual { fill: none; stroke: var(--accent-strong); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.pc-grafica .punto { fill: var(--accent-strong); stroke: var(--surface); stroke-width: 2; }
.pc-leyenda { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-muted); }
.pc-leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.pc-leyenda i { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--accent-strong); }
.pc-leyenda .l-anterior { border-top: 2px solid var(--harvest); }
.pc-leyenda .l-media { border-top: 2px dashed var(--step-2); }

/* Tablas por campaña. */
.pc-campanas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; align-items: start; }
.pc-campanas caption { text-align: left; font-weight: 600; padding: 12px 14px 6px; }
.pc-campanas th span { font-weight: 400; color: var(--text-muted); font-size: 13px; }
@media (max-width: 600px) { .pc-grafica .eje { font-size: 26px; } }
