/* AhorraMascotas: estilos mobile-first, accesibles y con modo oscuro. Índigo + coral, sin emojis. */
:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --text: #1d1f33;
  --muted: #595d78;
  --border: #d9dcea;
  --primary: #3d47a8;
  --primary-strong: #2d3586;
  --primary-contrast: #ffffff;
  --primary-soft: #e9ebfa;
  --accent: #e2574c;
  --accent-soft: #fdeceb;
  --ok: #1f7a55;
  --ok-soft: #e4f4ec;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --demo-bg: #fff1c2;
  --demo-text: #6b3e00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 31, 51, .06), 0 4px 14px rgba(29, 31, 51, .05);
  --focus: 0 0 0 3px rgba(61, 71, 168, .45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131f; --surface: #1b1d2d; --surface-2: #24273b; --text: #eceefa; --muted: #a9adc8; --border: #34384f;
    --primary: #9aa4ff; --primary-strong: #b9c0ff; --primary-contrast: #10122a; --primary-soft: #262b52;
    --accent: #ff8a7f; --accent-soft: #3f2220; --ok: #6fd3a5; --ok-soft: #173327; --warn: #f3c066; --warn-soft: #3a2d12;
    --danger: #ff8b80; --danger-soft: #3d1c19; --demo-bg: #3a2d12; --demo-text: #f8d68a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); line-height: 1.5; font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--primary); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: .4rem 0 .8rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1.02rem; margin: 0 0 .35rem; }
p { margin: .35rem 0 .7rem; }
small, .muted { color: var(--muted); }
.d-block { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }

/* Aviso de demostración */
.demo-banner { background: var(--demo-bg); color: var(--demo-text); padding: .4rem 1rem; font-size: .85rem; display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; align-items: center; text-align: center; }
.demo-banner strong { letter-spacing: .06em; border: 2px solid currentColor; border-radius: 6px; padding: 0 .35rem; font-size: .75rem; }

/* Cabecera y navegación */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); min-width: 0; }
.logo-svg { flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; line-height: 1.1; }
.brand-name .b1 { color: var(--primary); }
.brand-name .b2 { color: var(--accent); }
.brand small { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: .2rem; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .75rem; border-radius: 999px; text-decoration: none; color: var(--text); font-size: .92rem; white-space: nowrap; }
.tabs svg, .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ico { width: 18px; height: 18px; vertical-align: -3px; }
.tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-contrast); font-weight: 600; }
.tabs a:hover:not([aria-current="page"]) { background: var(--surface-2); }
@media (max-width: 899px) {
  .topbar .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--surface); border-top: 1px solid var(--border); justify-content: space-around; padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); }
  .topbar .tabs a { flex-direction: column; gap: .1rem; padding: .3rem .2rem; font-size: .7rem; border-radius: 10px; flex: 1 1 0; min-width: 0; }
  .topbar .tabs a[data-route="presupuesto"] span { font-size: .66rem; }
  .topbar .tabs a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  body.app { padding-bottom: 4.6rem; }
}

main { max-width: 1080px; margin: 0 auto; padding: 1rem; min-height: 60vh; }
main:focus { outline: none; }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 1.2rem 1rem 2rem; }
.footer p { margin: .25rem 0; }

/* Bloques */
.section { margin: 1.4rem 0; }
.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; }
@media (min-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.card.highlight { border: 2px solid var(--primary); }
.card.warn { border-color: var(--warn); background: var(--warn-soft); }
.card.error { border-color: var(--danger); background: var(--danger-soft); }
.card.info { background: var(--primary-soft); border-color: transparent; }
.ok-card { background: var(--ok-soft); border-color: transparent; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.plain { list-style: none; padding: 0; margin: 0; }
.notice { font-size: .88rem; color: var(--muted); border-left: 3px solid var(--accent); padding: .3rem 0 .3rem .7rem; }
.small-print { font-size: .82rem; color: var(--muted); }
.demo-note { font-size: .75rem; font-weight: 600; color: var(--warn); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; margin-left: .2rem; }
.tag.offer { background: var(--accent-soft); color: var(--accent); }
.tag.warn, .tag.pronto { background: var(--warn-soft); color: var(--warn); }
.tag.vencido { background: var(--danger-soft); color: var(--danger); }
.tag.al-dia { background: var(--ok-soft); color: var(--ok); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* Botones y formularios */
button, .btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; }
button:hover, .btn:hover { border-color: var(--primary); }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
button.primary:hover, .btn.primary:hover { background: var(--primary-strong); }
button.big, .btn.big { min-height: 52px; padding: .7rem 1.4rem; font-size: 1.05rem; }
button.small, .btn.small { min-height: 38px; padding: .3rem .7rem; font-size: .88rem; }
button.ghost, .btn.ghost { background: transparent; }
button.danger, .btn.danger { color: var(--danger); }
.btn.whatsapp { border-color: #1f8f55; color: #1f8f55; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .92rem; }
input, select, textarea { font: inherit; font-weight: 400; min-height: 44px; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: 1.15rem; min-height: 0; height: 1.15rem; accent-color: var(--primary); margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 .8rem; min-width: 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; padding: 0; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: 1fr; margin-bottom: .8rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form label { margin-bottom: .7rem; }
.form-grid label { margin-bottom: 0; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.seg legend { width: 100%; }
.seg label, .chip { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; min-height: 40px; }
.seg label:has(input:checked), .chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips legend { width: 100%; }
.check { flex-direction: row; align-items: center; gap: .4rem; }
.unit-hint { font-weight: 400; color: var(--muted); }
.form-actions { margin-top: 1rem; }
.feed-line { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; margin-bottom: .8rem; background: var(--surface-2); }
.feed-line legend { padding: 0 .3rem; }
.label-table { margin: .2rem 0 .6rem; }
.label-table summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 32px; }
.lt-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .4rem; }
.rer { font-size: .88rem; color: var(--muted); background: var(--primary-soft); border-radius: 10px; padding: .5rem .7rem; }
.rer[hidden] { display: none; }

/* Inicio */
.hero h1 { font-size: clamp(1.5rem, 4.5vw, 2.2rem); }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 62ch; }
.steps { list-style: none; counter-reset: s; padding: 0; display: grid; gap: .6rem; margin: 1rem 0; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { counter-increment: s; background: var(--surface-2); border-radius: 12px; padding: .75rem .9rem .75rem 3rem; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: .8rem; top: .75rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.steps strong, .steps span { display: block; }
.steps span { color: var(--muted); font-size: .92rem; }
.summary { display: grid; gap: .8rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 640px) { .summary { grid-template-columns: repeat(3, 1fr); } }
.summary .card { margin: 0; }
.kpi-card { display: flex; flex-direction: column; gap: .1rem; text-decoration: none; color: var(--text); }
a.kpi-card:hover { border-color: var(--primary); }
.kpi-label { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.kpi.small { font-size: 1.2rem; }
.pet-card h3 { margin: 0; }
.feed-list li { display: flex; flex-direction: column; padding: .4rem 0; border-top: 1px dashed var(--border); }
.cp-card form input { max-width: 8.5rem; }
.prevention { border-left: 4px solid var(--accent); }
.prevention .actions, .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Cesta */
.ctl { gap: 1rem; align-items: flex-end; }
.ctl label { flex: 1 1 14rem; }
.need-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.total-card { display: flex; flex-wrap: wrap; gap: 1.2rem 2.5rem; }
.total-card > div { display: flex; flex-direction: column; }
.scenario summary { display: flex; justify-content: space-between; gap: 1rem; cursor: pointer; font-weight: 700; min-height: 32px; align-items: center; }
.provider-block { margin-top: .9rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .45rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num, .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { border-bottom: 0; }
tr.total td { font-weight: 800; border-top: 2px solid var(--text); }
@media (min-width: 560px) { table.lines td:nth-child(2) { white-space: nowrap; } }
@media (max-width: 559px) {
  table.lines thead { display: none; }
  table.lines, table.lines tbody, table.lines tfoot { display: block; width: 100%; }
  table.lines tfoot tr { display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0; }
  table.lines tfoot td { border: 0; padding: 0; }
  table.lines tbody tr { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
  table.lines tbody td { border: 0; padding: 0; }
  table.lines tbody td:first-child { grid-column: 1 / -1; }
  table.lines tbody td:nth-child(2) { color: var(--muted); font-size: .88rem; }
}

/* Ofertas */
.store-strip { display: flex; gap: .8rem; margin-bottom: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .3rem; }
.store-strip > .card { flex: 0 0 80%; scroll-snap-align: start; }
@media (min-width: 640px) { .store-strip { display: grid; grid-template-columns: repeat(2, 1fr); overflow: visible; } }
@media (min-width: 960px) { .store-strip { grid-template-columns: repeat(4, 1fr); } }
.store-strip .card { margin: 0; }
.store-card h2 { font-size: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filters .grow { flex: 1 1 16rem; }
.filters .seg { margin: 0; }
.product .price { font-size: 1.3rem; font-weight: 800; color: var(--primary); margin: .2rem 0; }
.product .price small { font-size: .82rem; font-weight: 400; }
.product details summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.offers li { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-top: 1px dashed var(--border); }
.offers li.na { opacity: .7; }
.add-row { margin-top: .6rem; }
.add-row select { width: 4.5rem; }

/* Avisos */
.rem { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem; }
.rem.vencido { border-left: 4px solid var(--danger); }
.rem.pronto { border-left: 4px solid var(--warn); }
.ex-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .35rem 0; border-top: 1px dashed var(--border); }
.crumbs { font-size: .88rem; color: var(--muted); }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: calc(100vw - 2rem); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print { .topbar, .demo-banner .today, .footer, .toast, .actions, .ctl { display: none !important; } }
