/* calculaTor · Design System A "Lavanda Clay" (oscuro = B "Bosque Nocturno") · ver docs/DESIGN_SYSTEM.md */

/* ---------- Fuentes autoalojadas (OFL) ---------- */
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('../fonts/fredoka-600.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('../fonts/fredoka-700.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 500; font-display: swap; src: url('../fonts/nunito-500.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url('../fonts/nunito-700.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('../fonts/nunito-800.woff2') format('woff2'); }

/* ---------- Tokens ---------- */
:root {
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-card: 28px; --r-pill: 999px; --r-chip: 14px; --r-field: 18px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --nav-h: 76px;
  --col: 480px;
  --t-xs: .78rem; --t-sm: .9rem; --t-md: 1rem; --t-lg: 1.2rem; --t-xl: 1.55rem; --t-num: 1.75rem;
  --ease: cubic-bezier(.34, 1.4, .64, 1);

  /* Paleta A · 60-30-10 */
  --bg: #EEE8F9;            /* 60 lavanda niebla */
  --surface: #FBF9FE;       /* tarjetas claras */
  --chip: #E3DAF5;          /* chips */
  --field: #F3EEFC;
  --text: #10281A;          /* 30 verde bosque */
  --text-2: #3F5247;
  --line: #D8CCF0;
  --accent: #B4492F;        /* 10 ladrillo */
  --accent-text: #A9442C;
  --on-accent: #FFFFFF;
  --conv-bg: #10281A;       /* tarjeta del conversor */
  --conv-input: #1B3B29;
  --conv-text: #F3EEFC;
  --conv-text-2: #C3B2EE;
  --conv-focus: #E8775A;
  --nav-bg: #10281A;
  --nav-text: #C3B2EE;
  --nav-active-bg: #C3B2EE;
  --nav-active-text: #10281A;
  --best-bg: #B4492F;
  --best-text: #FFFFFF;
  --good: #2F7A4C;
  --warn: #A9442C;
  --stage-spot: transparent;

  /* Monedas (solo puntos y etiquetas) */
  --ves: #C3B2EE; --usd: #3E8A5B; --cop: #E8775A; --eur: #6E58B8;

  --clay: inset 0 2px 0 rgb(255 255 255 / .55), inset 0 -6px 14px rgb(16 40 26 / .10), 0 18px 30px -14px rgb(16 40 26 / .35);
  --clay-press: inset 0 2px 0 rgb(255 255 255 / .4), inset 0 -2px 6px rgb(16 40 26 / .12), 0 6px 12px -8px rgb(16 40 26 / .35);
  --clay-dark: inset 0 2px 0 rgb(255 255 255 / .10), inset 0 -8px 16px rgb(0 0 0 / .25), 0 18px 30px -14px rgb(16 40 26 / .55);
  --clay-inset: inset 0 3px 8px rgb(16 40 26 / .14), inset 0 -1px 0 rgb(255 255 255 / .6);
  --clay-inset-dark: inset 0 3px 8px rgb(0 0 0 / .35), inset 0 -1px 0 rgb(255 255 255 / .06);
  color-scheme: light;
}

/* Modo oscuro = combinación B */
[data-theme="dark"] {
  --bg: #10281A;
  --surface: #1B3B29;
  --chip: #24493A;
  --field: #143222;
  --text: #E9E2FA;
  --text-2: #C3B2EE;
  --line: #2E5641;
  --accent: #E8775A;
  --accent-text: #EE8D73;
  --on-accent: #10281A;
  --conv-bg: #C3B2EE;
  --conv-input: #D6CAF4;
  --conv-text: #10281A;
  --conv-text-2: #34483C;
  --conv-focus: #B4492F;
  --nav-bg: #0B1D12;
  --nav-text: #C3B2EE;
  --nav-active-bg: #C3B2EE;
  --nav-active-text: #10281A;
  --best-bg: #E8775A;
  --best-text: #10281A;
  --good: #7FD19D;
  --warn: #EE8D73;
  --stage-spot: #C3B2EE;
  --usd: #6CC08B;
  --clay: inset 0 2px 0 rgb(255 255 255 / .08), inset 0 -6px 14px rgb(0 0 0 / .22), 0 18px 30px -14px rgb(0 0 0 / .6);
  --clay-press: inset 0 2px 0 rgb(255 255 255 / .06), inset 0 -2px 6px rgb(0 0 0 / .25), 0 6px 12px -8px rgb(0 0 0 / .6);
  --clay-inset: var(--clay-inset-dark);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 500 var(--t-md)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
h1, h2 { font-size: var(--t-lg); }
h3 { font-family: var(--font-body); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--text-2); }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 3px; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 10px 16px; border-radius: var(--r-pill); }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num, input { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app {
  max-width: var(--col); margin: 0 auto;
  padding: 0 var(--s4) calc(var(--nav-h) + var(--s6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s3);
}
.main { display: flex; flex-direction: column; gap: var(--s4); outline: none; }
.tab { display: flex; flex-direction: column; gap: var(--s4); animation: tab-in .28s ease both; }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Escritorio: columna central de 480 px con Rem grande al lado */
@media (min-width: 960px) {
  .app {
    max-width: calc(var(--col) + 340px + var(--s8)); display: grid;
    grid-template-columns: 340px var(--col); column-gap: var(--s8); row-gap: var(--s3);
    grid-template-areas: "top top" "status status" "stage main";
    align-items: start;
  }
  .topbar { grid-area: top; }
  .status-bar { grid-area: status; }
  .stage { grid-area: stage; position: sticky; top: var(--s4); }
  .main { grid-area: main; }
}

/* ---------- Clay ---------- */
.clay { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--clay); }
.card { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.sub { color: var(--text-2); font-size: var(--t-sm); }
.note { color: var(--text-2); font-size: var(--t-xs); }
.stamp { font-size: var(--t-xs); color: var(--text-2); font-weight: 700; }
.empty { color: var(--text-2); font-size: var(--t-sm); text-align: center; padding: var(--s3) 0; }

/* ---------- Botones (siempre píldora) ---------- */
.btn, .icon-btn, .chip, .seg button, .quick button {
  border: 0; cursor: pointer; border-radius: var(--r-pill); min-height: 44px;
  transition: transform .15s var(--ease), box-shadow .15s ease, background-color .2s ease;
  -webkit-user-select: none; user-select: none;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); padding: 0 var(--s5); font-weight: 800; text-decoration: none; box-shadow: var(--clay); }
.btn.sm { min-height: 44px; padding: 0 var(--s4); font-size: var(--t-sm); }
.btn:active, .icon-btn:active, .chip:active, .quick button:active, .seg button:active { transform: translateY(2px); box-shadow: var(--clay-press); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: var(--chip); color: var(--text); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-ghost-dark { background: var(--conv-input); color: var(--conv-text); box-shadow: none; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface); color: var(--text); box-shadow: var(--clay); padding: 0; }
.icon-btn.sm { width: 40px; height: 40px; min-height: 40px; }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--s3); background: var(--chip); font-weight: 800; font-size: var(--t-sm); box-shadow: var(--clay); }
.chip svg { width: 18px; height: 18px; }
.chip .caret { width: 16px; height: 16px; }

/* SegmentedPill: la activa "sube" con clay */
.seg { display: flex; padding: 4px; gap: 4px; background: var(--chip); border-radius: var(--r-pill); box-shadow: var(--clay-inset); }
.seg button { flex: 1; background: transparent; padding: 0 var(--s3); font-weight: 800; font-size: var(--t-sm); color: var(--text-2); white-space: nowrap; min-height: 40px; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--clay); }
.seg-profile button[aria-checked="true"], .seg-mode button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.seg-mini { padding: 3px; }
.seg-mini button { min-height: 38px; min-width: 44px; padding: 0 10px; font-size: var(--t-xs); flex: none; }

/* ---------- Header ---------- */
.topbar { display: flex; flex-direction: column; gap: var(--s2); padding-top: calc(var(--s3) + env(safe-area-inset-top)); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.brand { display: flex; align-items: center; gap: var(--s2); text-decoration: none; color: var(--text); min-width: 0; }
.logo { width: 40px; height: 40px; color: var(--accent); filter: drop-shadow(0 6px 8px rgb(16 40 26 / .2)); }
.logo g { stroke: var(--on-accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; letter-spacing: -.01em; }
.brand-name b { color: var(--accent-text); font-weight: 700; }
.brand-sub { font-size: var(--t-xs); color: var(--text-2); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: var(--s2); }
.i-moon { display: none; }
[data-theme="dark"] .i-moon { display: block; }
[data-theme="dark"] .i-sun { display: none; }
.region { position: relative; }
.region-menu { position: absolute; z-index: 30; top: calc(100% + 8px); left: 0; min-width: 260px; list-style: none; margin: 0; padding: var(--s2); display: flex; flex-direction: column; gap: 4px; }
.region-menu li button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-pill); background: transparent; cursor: pointer; font-weight: 800; text-align: left; }
.region-menu li button[aria-selected="true"] { background: var(--chip); }
.region-menu li button:disabled { cursor: not-allowed; color: var(--text-2); }
.soon { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: var(--r-pill); background: var(--chip); color: var(--accent-text); }
.seg-mode { flex: none; }
.rl-short { display: none; }
@media (max-width: 420px) { .rl-full { display: none; } .rl-short { display: inline; } }
.seg-mode button { min-height: 40px; padding: 0 var(--s3); }

/* ---------- Barra de estado ---------- */
.status-bar { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-xs); font-weight: 700; color: var(--text-2); padding: 2px var(--s2); }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--usd); box-shadow: 0 0 0 0 rgb(62 138 91 / .5); animation: pulse 2s infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(62 138 91 / .5); } 70% { box-shadow: 0 0 0 8px rgb(62 138 91 / 0); } 100% { box-shadow: 0 0 0 0 rgb(62 138 91 / 0); } }
.status-bar.loading .pulse { background: var(--ves); }
.status-bar.err { color: var(--warn); }
.status-bar.err .pulse { background: var(--accent); animation: none; }

/* ---------- Rem: escenario / tarjeta "Te conviene" ---------- */
.stage { position: relative; display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4) var(--s2) var(--s2); min-height: 108px; transition: background-color .35s ease, color .35s ease; overflow: visible; }
.rem-figure { position: relative; width: 96px; height: 96px; flex: none; border-radius: 50%; cursor: pointer; touch-action: none; outline-offset: 4px; }
.rem-figure::before { content: ''; position: absolute; inset: 10% 6% 2%; border-radius: 50%; background: radial-gradient(closest-side, var(--stage-spot), transparent); opacity: .55; }
.rem-figure canvas { position: absolute; inset: -22%; width: 144% !important; height: 144% !important; }
@media (min-width: 960px) { .rem-figure canvas { inset: -18%; width: 136% !important; height: 136% !important; } }
.tv-rem .rem-figure canvas { inset: -10%; width: 120% !important; height: 120% !important; }
.rem-img { position: relative; width: 100%; height: 100%; object-fit: contain; animation: rem-float 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.rem-figure.has-3d .rem-img { display: none; }
.rem-figure.squish .rem-img { animation: rem-squish .5s var(--ease); }
.rem-figure[data-state="sorprendido"] .rem-img { animation: rem-shake .6s ease 2; }
.rem-figure[data-state="celebra"] .rem-img { animation: rem-jump .7s var(--ease) 2; }
.rem-figure[data-state="dormido"] .rem-img { animation: rem-breath 3.6s ease-in-out infinite; }
@keyframes rem-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes rem-breath { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.02); } }
@keyframes rem-squish { 0% { transform: scale(1); } 30% { transform: scale(1.1, .9); } 60% { transform: scale(.95, 1.05); } 100% { transform: scale(1); } }
@keyframes rem-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
@keyframes rem-jump { 0%, 100% { transform: translateY(0) scale(1); } 30% { transform: translateY(2px) scale(1.06, .92); } 55% { transform: translateY(-10px) scale(.96, 1.05); } }
.stage-body { flex: 1; min-width: 0; position: relative; }
.bubble { position: relative; background: var(--chip); border-radius: 20px; padding: 10px 14px; font-weight: 700; font-size: var(--t-sm); line-height: 1.35; box-shadow: var(--clay-press); animation: bubble-in .35s var(--ease) both; }
.bubble::before { content: ''; position: absolute; left: -7px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-left: 0; border-right-color: var(--chip); }
.bubble:empty { display: none; }
@keyframes bubble-in { from { opacity: 0; transform: scale(.92) translateX(-6px); } to { opacity: 1; transform: none; } }
.stage-hint { color: var(--text-2); font-size: var(--t-sm); font-weight: 700; }
.bubble:not(:empty) ~ .stage-hint { display: none; }
.mute-btn { position: absolute; top: -10px; right: -6px; box-shadow: var(--clay); }
.mute-btn .i-off { display: none; }
.mute-btn[aria-pressed="true"] .i-off { display: block; }
.mute-btn[aria-pressed="true"] .i-on { display: none; }

/* Tarjeta firma "Te conviene" */
.stage.has-best { background: var(--best-bg); color: var(--best-text); }
.stage.has-best .stage-hint, .stage.has-best .bubble { display: none; }
.best { display: flex; flex-direction: column; gap: 2px; position: relative; }
.best-kicker { font-size: var(--t-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.best-cur { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1; display: flex; align-items: center; gap: 8px; }
.best-cur .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 3px rgb(255 255 255 / .55); }
.best-detail { font-size: var(--t-sm); font-weight: 700; }
.float-badge {
  position: absolute; display: inline-block; padding: 6px 12px; border-radius: var(--r-pill);
  font-weight: 800; font-size: var(--t-sm); font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--surface); color: var(--text); box-shadow: var(--clay);
  transform: rotate(var(--tilt, -4deg)); animation: badge-float 4s ease-in-out infinite;
}
.float-badge:empty { display: none; }
@keyframes badge-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
.best-badge { position: relative; margin-left: 6px; font-family: var(--font-body); font-size: var(--t-sm); --tilt: -6deg; color: var(--accent-text); }

@media (min-width: 960px) {
  .stage { flex-direction: column; align-items: stretch; text-align: left; padding: var(--s5); gap: var(--s4); min-height: 420px; }
  .rem-figure { width: 260px; height: 260px; align-self: center; }
  .bubble::before { left: 50%; top: -7px; margin: 0 0 0 -8px; border: 8px solid transparent; border-top: 0; border-bottom-color: var(--chip); }
  .best-cur { font-size: 2.6rem; }
  .mute-btn { top: var(--s3); right: var(--s3); }
}

/* ---------- Selector de tasa y Mi tasa ---------- */
.rate-picker { display: flex; flex-direction: column; gap: var(--s2); }
.picker-note { font-size: var(--t-xs); color: var(--text-2); padding: 0 var(--s2); }
.custom-rates { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.custom-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.label { font-size: var(--t-xs); font-weight: 800; color: var(--text-2); }
.field input, .field select {
  width: 100%; min-height: 48px; border: 2px solid transparent; border-radius: var(--r-field); padding: 0 var(--s3);
  background: var(--field); box-shadow: var(--clay-inset); font-weight: 700; font-size: var(--t-md); color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); }

/* ---------- Conversor (tarjeta verde bosque) ---------- */
.converter { position: relative; background: var(--conv-bg); color: var(--conv-text); border-radius: var(--r-card); padding: var(--s4); box-shadow: var(--clay-dark); display: flex; flex-direction: column; gap: var(--s3); }
.conv-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.conv-head h1 { font-size: var(--t-md); color: var(--conv-text-2); font-weight: 600; }
.rows { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); background: var(--conv-input); border-radius: var(--r-pill); padding: 4px var(--s4) 4px 6px; border: 3px solid transparent; transition: border-color .2s; min-height: 60px; box-shadow: inset 0 3px 8px rgb(0 0 0 / .25); }
.row.active { border-color: var(--conv-focus); }
.row .tag { display: flex; align-items: center; gap: 8px; flex: none; min-width: 76px; padding: 0 10px; height: 44px; border-radius: var(--r-pill); background: rgb(255 255 255 / .06); }
.row .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--cur); flex: none; }
.row .code { font-weight: 800; font-size: var(--t-sm); letter-spacing: .04em; }
.row .sym { font-size: var(--t-xs); color: var(--conv-text-2); font-weight: 700; }
.row input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; text-align: right; font-family: var(--font-display); font-weight: 600; font-size: var(--t-num); color: var(--conv-text); padding: 0; }
.row input::placeholder { color: var(--conv-text-2); opacity: .55; }
.bump { animation: bump .32s var(--ease); }
@keyframes bump { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.quick { display: flex; flex-wrap: wrap; gap: var(--s2); }
/* Espacio reservado antes de que el JS pinte (evita CLS en la carga): 4 filas, 2 líneas de montos, 1 selector. */
.rows:empty { min-height: 264px; }
.quick:empty { min-height: 96px; }
.seg-profile:empty { min-height: 48px; }
.quick button { background: var(--conv-input); color: var(--conv-text); padding: 0 var(--s3); font-weight: 800; font-size: var(--t-sm); box-shadow: inset 0 2px 0 rgb(255 255 255 / .08), 0 6px 10px -6px rgb(0 0 0 / .5); }
.conv-badge { right: 14px; top: -14px; --tilt: 5deg; background: var(--chip); color: var(--text); font-size: var(--t-xs); }

/* ---------- Comparador ---------- */
.cmp-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.cmp-field .label { display: flex; align-items: center; gap: 6px; }
.cmp-field .label::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--cur); }
.cmp-out { display: flex; flex-direction: column; gap: var(--s2); }
.cmp-item { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: 22px; background: var(--field); box-shadow: var(--clay-inset); }
.cmp-item .who { font-weight: 800; flex: 1; min-width: 0; }
.cmp-item .val { flex: none; }
.cmp-item .who span { display: block; font-weight: 600; font-size: var(--t-xs); color: var(--text-2); }
.cmp-item .val { text-align: right; font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-item .val small { display: block; font-family: var(--font-body); font-size: var(--t-xs); color: var(--text-2); font-weight: 700; }
.cmp-item.best { background: var(--best-bg); color: var(--best-text); box-shadow: var(--clay); }
.cmp-item.best .who span, .cmp-item.best .val small { color: inherit; opacity: .9; }
.badge { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); background: rgb(255 255 255 / .25); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Tasas ---------- */
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.rate-card { position: relative; padding: var(--s3) var(--s4); border-radius: 22px; background: var(--field); box-shadow: var(--clay-inset); }
.rate-card .k { font-size: var(--t-xs); font-weight: 800; color: var(--text-2); }
.rate-card .v { font-family: var(--font-display); font-weight: 600; font-size: var(--t-lg); font-variant-numeric: tabular-nums; }
.rate-card .src { font-size: .72rem; color: var(--text-2); font-weight: 600; }
.cheat { display: grid; gap: var(--s4); }
.cheat-col h4 { font-family: var(--font-body); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); font-weight: 800; margin-bottom: var(--s2); }
.cheat-row { display: flex; justify-content: space-between; gap: var(--s3); padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.cheat-row .to { color: var(--text-2); text-align: right; font-weight: 700; }
.fold > summary { list-style: none; cursor: pointer; min-height: 44px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ''; width: 10px; height: 10px; border-right: 2.5px solid var(--text-2); border-bottom: 2.5px solid var(--text-2); transform: rotate(45deg); margin-left: auto; transition: transform .2s; }
.fold[open] > summary::after { transform: rotate(225deg); }
.sources ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--t-sm); color: var(--text-2); }
.sources b { color: var(--text); }

/* Historial */
.history { display: flex; flex-direction: column; gap: var(--s2); }
.spark { width: 100%; height: auto; display: block; overflow: visible; }
.spark .area { fill: var(--ves); opacity: .3; }
.spark .line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .pt { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.hist-meta { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.hist-now { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 600; font-variant-numeric: tabular-nums; position: relative; display: inline-block; }
.hist-now .float-badge { right: -80px; top: -8px; position: absolute; }
.collecting { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.dots7 { display: flex; gap: 6px; }
.dots7 i { width: 14px; height: 14px; border-radius: 50%; background: var(--chip); box-shadow: var(--clay-inset); }
.dots7 i.on { background: var(--usd); box-shadow: var(--clay); }

/* ---------- Lista ---------- */
.list-form { display: flex; flex-direction: column; gap: var(--s3); }
.li-price-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: end; }
.li-more summary { cursor: pointer; font-weight: 800; font-size: var(--t-sm); color: var(--accent-text); min-height: 44px; display: flex; align-items: center; }
.li-alt { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.li-actions { display: flex; gap: var(--s2); align-items: end; }
.li-actions .qty { width: 90px; flex: none; }
.li-actions .btn { flex: 1; min-height: 48px; }
.list-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.list-items li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-radius: 22px; background: var(--field); box-shadow: var(--clay-inset); }
.list-items .li-info { flex: 1; min-width: 0; }
.list-items .li-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-items .li-prices { font-size: var(--t-xs); color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.list-total { display: flex; flex-direction: column; gap: var(--s2); }
.tot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.tot { padding: var(--s3); border-radius: 20px; background: var(--chip); }
.tot .k { font-size: var(--t-xs); font-weight: 800; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tot .k::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--cur); }
.tot .v { font-family: var(--font-display); font-weight: 600; font-size: var(--t-lg); font-variant-numeric: tabular-nums; }
.tot.win { background: var(--best-bg); color: var(--best-text); box-shadow: var(--clay); }
.tot.win .k { color: inherit; }
.list-reco { font-weight: 800; padding: var(--s3) var(--s4); border-radius: 20px; background: var(--chip); }

/* ---------- Comercio ---------- */
.biz-form { display: flex; flex-direction: column; gap: var(--s3); }
.pin-field { max-width: 200px; }
.pin-field input { letter-spacing: .5em; font-size: var(--t-lg); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.form-msg { font-weight: 800; font-size: var(--t-sm); color: var(--warn); min-height: 1.2em; }
.form-msg.ok { color: var(--good); }
.biz-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.biz-summary .rate-card { padding: var(--s2) var(--s3); }
.biz-summary .rate-card .v { font-size: .95rem; white-space: nowrap; }
.tot.win .note { color: inherit; }
.biz-cmp { grid-column: 1 / -1; font-weight: 800; font-size: var(--t-sm); padding: var(--s2) var(--s3); border-radius: var(--r-pill); background: var(--chip); text-align: center; }
.unlock { display: flex; gap: var(--s2); align-items: end; margin-top: var(--s3); }
.unlock .field { max-width: 160px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s4); border-radius: 24px; background: #FBF9FE; color: #10281A; box-shadow: var(--clay-inset); }
.qr { width: min(240px, 70vw); aspect-ratio: 1; }
.qr svg, .tv-qr svg { width: 100%; height: 100%; display: block; stroke: none; }
.qr-name { font-family: var(--font-display); font-weight: 600; font-size: var(--t-lg); text-align: center; }
.qr-link { font-size: var(--t-xs); word-break: break-all; text-align: center; }
.shared-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--chip); }
.shared-banner p { display: flex; flex-direction: column; font-size: var(--t-xs); font-weight: 700; color: var(--text-2); }
.shared-banner b { font-family: var(--font-display); font-size: var(--t-md); color: var(--text); font-weight: 600; }

/* Modo TV */
.tv { position: fixed; inset: 0; z-index: 60; background: var(--bg); color: var(--text); overflow: auto; }
.tv-inner { min-height: 100%; display: grid; gap: var(--s5); padding: clamp(16px, 4vw, 48px); grid-template-columns: 1fr; align-content: center; }
.tv-head { text-align: center; }
.tv-kicker { font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--accent-text); font-size: clamp(.8rem, 1.6vw, 1.2rem); }
.tv-name { font-size: clamp(1.8rem, 5vw, 4rem); font-weight: 700; }
.tv-time { color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-rates { display: grid; gap: var(--s3); }
.tv-rate { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: clamp(12px, 2.4vw, 28px) clamp(16px, 3vw, 36px); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--clay); }
.tv-rate .k { font-weight: 800; font-size: clamp(1rem, 2.4vw, 1.8rem); display: flex; align-items: center; gap: 10px; }
.tv-rate .k::before { content: ''; width: .7em; height: .7em; border-radius: 50%; background: var(--cur); }
.tv-rate .v { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 7vw, 5.5rem); font-variant-numeric: tabular-nums; line-height: 1; }
.tv-side { display: flex; align-items: center; justify-content: center; gap: var(--s5); flex-wrap: wrap; }
.tv-rem { width: clamp(120px, 18vw, 240px); aspect-ratio: 1; position: relative; }
.tv-rem .rem-figure { width: 100%; height: 100%; }
.tv-qr { width: clamp(120px, 16vw, 220px); aspect-ratio: 1; background: #FBF9FE; border-radius: 20px; padding: 10px; box-shadow: var(--clay); }
.tv-scan { font-weight: 800; color: var(--text-2); max-width: 12em; }
.tv-foot { text-align: center; color: var(--text-2); font-size: var(--t-xs); font-weight: 700; }
.tv-close { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; }
@media (min-width: 900px) and (orientation: landscape) {
  .tv-inner { grid-template-columns: 1.6fr 1fr; grid-template-areas: "head head" "rates side" "foot foot"; }
  .tv-head { grid-area: head; } .tv-rates { grid-area: rates; } .tv-side { grid-area: side; flex-direction: column; } .tv-foot { grid-area: foot; }
}

/* ---------- Navegación inferior ---------- */
.bottom-nav {
  position: fixed; z-index: 40; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(calc(100% - 20px), var(--col)); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 6px; background: var(--nav-bg); border-radius: var(--r-pill); box-shadow: var(--clay-dark);
}
.bottom-nav button {
  position: relative; border: 0; background: transparent; color: var(--nav-text); border-radius: var(--r-pill); min-height: 56px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 800; font-size: .72rem;
  transition: background-color .2s, color .2s, transform .15s var(--ease);
}
.bottom-nav button[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: var(--clay); }
.bottom-nav button:active { transform: translateY(2px); }
.nav-count { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: .66rem; line-height: 18px; }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--r-pill); font-weight: 800; font-size: var(--t-sm); box-shadow: var(--clay-dark); max-width: calc(100% - 32px); text-align: center; }

.foot { text-align: center; font-size: var(--t-xs); color: var(--text-2); padding: var(--s3) var(--s4); }
.foot span { opacity: .8; }
.foot { display: flex; flex-direction: column; align-items: center; gap: var(--s3); }

@media (max-width: 380px) {
  .brand-sub { display: none; }
  .seg-mode button { padding: 0 10px; font-size: .8rem; }
  .custom-fields, .li-alt { grid-template-columns: 1fr 1fr; }
  .row .tag { min-width: 70px; }
  :root { --t-num: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
