:root {
  color-scheme: dark;
  --bg: #0f172a; --bg2: #1e293b; --card: #162032; --border: #2a3a52; --border2: #35496a;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --accent2: #0ea5e9; --accent-ink: #082f49;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --gift: #a855f7; --pay: #f472b6;
  --radius: 14px; --radius-sm: 10px; --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
body.modal-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: var(--radius-sm); padding: 10px 14px; min-height: var(--tap); background: var(--bg2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:active { transform: scale(.98); }
button.primary { background: var(--accent2); color: #fff; font-weight: 600; }
button.danger { background: #7f1d1d; color: #fecaca; }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 8px 12px; font-size: 14px; min-height: 40px; }
button.icon { width: var(--tap); padding: 0; font-size: 20px; }
button.block { width: 100%; }
button:disabled { opacity: .55; cursor: default; transform: none; }
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; min-height: var(--tap); outline: none; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
label.inline { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; min-height: var(--tap); margin: 0; }
label.inline input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field-error { color: #fca5a5; font-size: 13px; margin-top: 6px; min-height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header { position: sticky; top: 0; z-index: 10; background: rgba(15,23,42,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: calc(10px + var(--safe-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
header h1 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
header h1 span { font-weight: 400; color: var(--muted); }
.status-chip { border: 1px solid var(--border); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: 12px; min-height: 36px; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-chip.on { border-color: #166534; color: #86efac; }
.status-chip.warn { border-color: #78350f; color: #fcd34d; }

main { padding: 14px 16px calc(96px + var(--safe-bottom)); max-width: 980px; margin: 0 auto; }
#view-products { padding-bottom: 70px; }
.view { display: none; } .view.active { display: block; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg2); border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 4px 0 calc(4px + var(--safe-bottom)); z-index: 10; }
nav.tabs button { background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 8px; min-height: 56px; position: relative; flex: 1; border-radius: 0; }
nav.tabs button[aria-current="page"] { color: var(--accent); }
nav.tabs button .ico { font-size: 22px; line-height: 1; }
nav.tabs .badge { position: absolute; top: 4px; right: calc(50% - 26px); background: var(--bad); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 5px; min-width: 16px; }

.toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
@media (min-width: 640px) { .toolbar { grid-template-columns: 1.4fr 1fr 1fr; } }
.toolbar input, .toolbar select { min-height: 42px; padding: 8px 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 8px; padding: 0 2px; cursor: pointer; min-height: var(--tap); }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.section-head .count { background: var(--bg2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); }
.section-head .arrow { color: var(--muted); transition: transform .15s; }
.section-head[aria-expanded="false"] .arrow { transform: rotate(-90deg); }
.section-body[hidden] { display: none; }
.chip.size { border-color: var(--border2); color: var(--text); font-variant-numeric: tabular-nums; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; min-width: 0; }
.card.paused { opacity: .7; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.price { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price small { font-size: 13px; color: var(--muted); font-weight: 400; text-decoration: line-through; margin-left: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--bg2); border: 1px solid var(--border); margin: 2px 4px 2px 0; max-width: 100%; overflow-wrap: anywhere; }
.chip.promo { border-color: var(--warn); color: #fcd34d; }
.chip.pay { border-color: var(--pay); color: #f9a8d4; }
.chip.gift { border-color: var(--gift); color: #d8b4fe; }
.chip.down { border-color: var(--ok); color: #86efac; }
.chip.up { border-color: var(--bad); color: #fca5a5; }
.chip.store { border-color: var(--accent); color: #7dd3fc; }
.chip.best { background: #14532d; border-color: var(--ok); color: #bbf7d0; }
.chip.off { border-color: var(--border2); color: var(--muted); }
a.chip { min-height: 40px; padding: 8px 12px; }

.watch { border-top: 1px dashed var(--border); padding: 12px 0 4px; }
.watch:first-of-type { border-top: 0; }
.thumb { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 10px; flex: none; }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; background: var(--bg2); color: var(--muted); font-size: 26px; }
.watch .err { color: #fca5a5; font-size: 13px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 100%; margin-top: 4px; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm); min-width: 220px; z-index: 5; box-shadow: 0 10px 30px rgba(0,0,0,.45); overflow: hidden; }
.menu button { display: flex; width: 100%; justify-content: flex-start; border-radius: 0; background: transparent; min-height: 46px; }
.menu button:hover, .menu button:focus-visible { background: var(--card); }
.menu button.danger { color: #fca5a5; background: transparent; }

.alert { display: flex; gap: 12px; align-items: flex-start; }
.alert img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.alert .body { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.alert.unread { border-color: var(--accent); }
.kind { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.fab { position: fixed; right: 18px; bottom: calc(78px + var(--safe-bottom)); width: 58px; height: 58px; border-radius: 50%; background: var(--accent2); color: #fff; font-size: 30px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 11; padding: 0; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: flex-end; justify-content: center; z-index: 20; }
.modal.open { display: flex; }
.modal .sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); border: 1px solid var(--border); }
@media (min-width: 700px) { .modal { align-items: center; } .modal .sheet { border-radius: 18px; } }
.sheet h2 { margin: 0; font-size: 18px; }
details.adv { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; margin-top: 14px; }
details.adv summary { cursor: pointer; color: var(--muted); padding: 12px 0; min-height: var(--tap); display: flex; align-items: center; list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: '▸'; margin-right: 8px; transition: transform .15s; }
details.adv[open] summary::before { transform: rotate(90deg); }
details.adv > div { padding-bottom: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + var(--safe-top)); background: #0c4a6e; color: #e0f2fe; padding: 10px 14px; border-radius: 12px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 92vw; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.show { opacity: 1; pointer-events: auto; }
.toast.err { background: #7f1d1d; color: #fecaca; }
.toast button { background: rgba(255,255,255,.15); color: inherit; min-height: 36px; padding: 6px 10px; }
.spark { width: 100%; height: 56px; display: block; }
.hist-list { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.hist-list .muted { font-size: 13px; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 10px; min-height: 52px; }
.list-item:last-child { border-bottom: 0; }
.list-item b { overflow-wrap: anywhere; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border2); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:disabled + span { opacity: .5; }
.tgmsg { border-top: 1px dashed var(--border); padding: 10px 0; font-size: 14px; }
.tgmsg .meta { color: var(--muted); font-size: 12px; }
.tgmsg .text { white-space: pre-wrap; margin: 4px 0; overflow-wrap: anywhere; }
.tgmsg a { display: block; overflow-wrap: anywhere; min-height: 32px; }
.tgmsg img { max-width: 100%; max-height: 240px; border-radius: 8px; margin-top: 6px; }
.tgmsg.hit { border-left: 3px solid var(--ok); padding-left: 8px; }
code { background: var(--bg2); padding: 2px 6px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }
pre { background: var(--bg2); padding: 10px; border-radius: 10px; overflow: auto; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.steps { display: grid; gap: 10px; margin: 14px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--bg2); border-radius: var(--radius-sm); padding: 12px; text-align: left; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); min-height: 64px; }
.setting:last-child { border-bottom: 0; }
.setting .title { font-weight: 600; }
/* Pantallas anchas (web en PC): contenido, barra de pestañas y botón flotante alineados a una columna central */
@media (min-width: 900px) {
  nav.tabs { left: 50%; right: auto; transform: translateX(-50%); width: 100%; max-width: 980px; border: 1px solid var(--border); border-radius: 16px 16px 0 0; }
  nav.tabs button { min-height: 60px; font-size: 12px; }
  .fab { right: calc(50% - 490px + 18px); }
  .toast { top: auto; bottom: calc(96px + var(--safe-bottom)); }
  .modal .sheet { max-height: 85vh; }
}
.install-banner { background: linear-gradient(135deg, #0c4a6e, #1e3a8a); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; display: none; }
.install-banner.show { display: block; }
.preview { display: flex; gap: 12px; align-items: center; background: var(--bg2); border-radius: var(--radius-sm); padding: 10px; margin-top: 10px; min-height: 60px; }
.preview .thumb { width: 56px; height: 56px; }
.skeleton { background: linear-gradient(90deg, var(--bg2) 25%, #243247 50%, var(--bg2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); height: 120px; margin-bottom: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }
#pinGate { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: none; align-items: center; justify-content: center; padding: 24px; }
#pinGate.show { display: flex; }
#pinGate .card { width: 100%; max-width: 420px; }
.native .hide-native { display: none !important; }
