/* Tasas CierraK · tokens de la identidad CierraK (ENTREGA_CIERRA/1-identidad). */
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(/fonts/Inter-400.woff2?v=2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(/fonts/Inter-500.woff2?v=2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(/fonts/Inter-600.woff2?v=2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(/fonts/Inter-700.woff2?v=2) format("woff2"); }

:root {
  color-scheme: light;
  --primary: #b84a0b;
  --primary-3: #fce3d1;
  --seed: #f26b1d;
  --accent: #1f6f82;
  --bg: #f6f8fb;
  --bg-alt: #eef2f7;
  --card: #ffffff;
  --border: #e3e8ef;
  --border-strong: #cbd3e0;
  --text: #0f1b32;
  --muted: #4a5870;
  --dim: #667085;
  --up: #0b7a55;
  --down: #c42b2b;
  --warn-bg: #fdf3e0;
  --warn-fg: #6b4304;
  --compra: #b84a0b;
  --venta: #1f6f82;
  --shadow: 0 1px 2px rgba(16, 29, 54, .06), 0 4px 14px rgba(16, 29, 54, .05);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: #f26b1d; --primary-3: #3a2416; --seed: #f26b1d; --accent: #5fb6c8;
    --bg: #0b1220; --bg-alt: #131d2e; --card: #161f31; --border: #28344a; --border-strong: #3a4866;
    --text: #eef3fb; --muted: #aebccf; --dim: #8a98ae; --up: #34d399; --down: #f06a6a;
    --warn-bg: #3a2e12; --warn-fg: #f6dc9a; --compra: #f58c4f; --venta: #5fb6c8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #f26b1d; --primary-3: #3a2416; --seed: #f26b1d; --accent: #5fb6c8;
  --bg: #0b1220; --bg-alt: #131d2e; --card: #161f31; --border: #28344a; --border-strong: #3a4866;
  --text: #eef3fb; --muted: #aebccf; --dim: #8a98ae; --up: #34d399; --down: #f06a6a;
  --warn-bg: #3a2e12; --warn-fg: #f6dc9a; --compra: #f58c4f; --venta: #5fb6c8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Barra */
.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: 8px; min-width: 0; }
.simbolo { display: block; }
.simbolo.oscuro { display: none; }
:root[data-theme="dark"] .simbolo.claro { display: none; }
:root[data-theme="dark"] .simbolo.oscuro { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .simbolo.claro { display: none; }
  :root:not([data-theme="light"]) .simbolo.oscuro { display: block; }
}
.logo { font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo b { color: var(--seed); font-weight: 800; }
.sep { width: 1px; height: 18px; background: var(--border-strong); }
.titulo { font-weight: 500; color: var(--muted); }
.acciones { display: flex; align-items: center; gap: 4px; }
.estado { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--dim); margin-right: 4px; white-space: nowrap; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.estado.vivo .punto { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.estado.error .punto { background: var(--down); }
.icono {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--muted);
}
.icono:hover { background: var(--bg-alt); color: var(--text); }
.icono svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icono.girando svg { animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.luna { display: none; }
:root[data-theme="dark"] .sol { display: none; }
:root[data-theme="dark"] .luna { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sol { display: none; }
  :root:not([data-theme="light"]) .luna { display: block; }
}

/* Rejilla */
.contenido {
  max-width: 1080px; margin: 0 auto; padding: 16px;
  display: grid; gap: 14px; grid-template-columns: 1fr;
}
@media (min-width: 820px) {
  .contenido { grid-template-columns: 1fr 1fr; padding: 24px; gap: 18px; }
  .diferencial { grid-column: 1 / -1; }
  .calc { grid-column: 2; grid-row: 3 / span 2; }
}

.tarjeta {
  scroll-margin-top: 76px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.cab { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; }
h2 { white-space: nowrap; margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.nota { font-size: 12.5px; color: var(--dim); }
.pie { margin: 14px 0 0; font-size: 12.5px; color: var(--dim); }

/* Diferencial */
.diferencial { display: grid; gap: 14px; }
.diferencial .cab { margin-bottom: 0; }
.dif-cifra { font-size: clamp(44px, 11vw, 68px); font-weight: 700; letter-spacing: -.035em; line-height: 1; color: var(--primary); }
.dif-barra { height: 8px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; }
.dif-barra span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--seed), var(--primary)); border-radius: inherit; transition: width .6s cubic-bezier(.2, .7, .2, 1); }
.dif-detalle { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.dif-detalle div { min-width: 0; }
.dif-detalle dt { font-size: 12.5px; color: var(--dim); }
.dif-detalle dd { margin: 2px 0 0; font-weight: 600; font-size: 16px; }
@media (max-width: 420px) { .dif-detalle dd { font-size: 14.5px; } }

/* Cifras */
.par { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cifra { display: grid; gap: 2px; min-width: 0; padding: 12px; border-radius: 12px; background: var(--bg-alt); }
.etq { font-size: 13px; color: var(--muted); font-weight: 500; }
.valor { font-size: clamp(22px, 6.4vw, 30px); font-weight: 700; letter-spacing: -.025em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.valor small { font-size: 13px; font-weight: 500; color: var(--dim); margin-left: 4px; letter-spacing: 0; }
.var, .sub { font-size: 12.5px; color: var(--dim); min-height: 18px; }
.var.sube { color: var(--up); }
.var.baja { color: var(--down); }
.aviso {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px;
  background: var(--warn-bg); color: var(--warn-fg);
}
.aviso b { font-weight: 600; }

/* Gráfica */
.grafica { margin: 14px 0 0; }
.grafica svg { width: 100%; height: 64px; display: block; overflow: visible; }
.grafica path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.grafica .l-compra { stroke: var(--compra); }
.grafica .l-venta { stroke: var(--venta); }
.grafica figcaption { display: flex; gap: 14px; margin-top: 8px; font-size: 12.5px; color: var(--dim); }
.grafica figcaption span:last-child { margin-left: auto; }
.ley::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.ley.compra::before { background: var(--compra); }
.ley.venta::before { background: var(--venta); }

/* Lista de otras tasas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: baseline; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); }
.lista li:first-child { border-top: 0; padding-top: 2px; }
.lista .cod { font-weight: 600; width: 44px; flex: none; }
.lista .nom { color: var(--muted); flex: 1; min-width: 0; font-size: 14px; }
.lista .nom small { display: block; color: var(--dim); font-size: 12px; }
.lista .val { font-weight: 600; white-space: nowrap; }
.lista.compacta { margin-top: 12px; }
.lista.compacta li:first-child { border-top: 1px solid var(--border); padding-top: 11px; }

/* Calculadora */
.enlace { border: 0; background: none; color: var(--accent); font-size: 13.5px; font-weight: 500; cursor: pointer; padding: 10px 4px; margin: -10px -4px; }
.campo {
  display: flex; align-items: stretch; border: 1.5px solid var(--border-strong); border-radius: 14px;
  background: var(--card); overflow: hidden; transition: border-color .15s;
}
.campo:focus-within { border-color: var(--primary); }
.campo input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 14px;
  font-size: 26px; font-weight: 600; letter-spacing: -.02em; outline: none;
}
.campo select {
  border: 0; border-left: 1px solid var(--border); background: var(--bg-alt); padding: 0 12px; font-weight: 600;
  font-size: 14.5px; cursor: pointer; min-height: 52px; outline: none;
}
.opciones { display: grid; gap: 8px; margin: 12px 0 4px; }
.seg { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.seg-etq { font-size: 12.5px; color: var(--dim); width: 84px; flex: none; }
.seg button {
  border: 1px solid var(--border); background: transparent; border-radius: 99px; padding: 6px 12px; min-height: 36px;
  font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.seg button[aria-checked="true"] { background: var(--primary-3); border-color: transparent; color: var(--text); font-weight: 600; }
.resultados { list-style: none; margin: 8px 0 0; padding: 0; }
.resultados li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.resultados li:first-child { border-top: 0; }
.resultados .nom { flex: 1; min-width: 0; }
.resultados .nom span { display: block; font-size: 12px; color: var(--dim); }
.resultados .val { font-size: 19px; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; }
.copiar {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; background: transparent;
  border-radius: 10px; color: var(--dim); cursor: pointer;
}
.copiar:hover { background: var(--bg-alt); color: var(--text); }
.copiar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copiar.ok { color: var(--up); }

.pie-pagina { max-width: 1080px; margin: 0 auto; padding: 4px 16px calc(28px + env(safe-area-inset-bottom)); font-size: 12.5px; color: var(--dim); }

.cargando .valor > span:first-child, .cargando #dif-pct { color: transparent; background: var(--bg-alt); border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 520px) { .estado span { display: none; } .estado { margin-right: 0; } }
