:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5f6673;
  --border: #dde1e7;
  --accent: #007e69;
  --brand-green: #00b894;
  --brand-gold: #f5bd39;
  --brand-ink: #052e26;
  --brand-fill: linear-gradient(135deg, #20c9a5, #00b894);
  --brand-fill-hover: linear-gradient(135deg, #43dfbd, #16c9a3);
  --pos: #137a4b;
  --neg: #b42318;
  --warn: #a15c07;
  --chart-line: #2f5fd0;
  --chart-fill: rgba(47, 95, 208, 0.12);
  --c0: #2f5fd0;
  --c1: #137a4b;
  --c2: #b7791f;
  --c3: #8e44ad;
  --c4: #0e8a91;
  --c5: #c2410c;
  --c6: #6b7280;
  --radius: 10px;
  color-scheme: light;
}

/* Oscuro: sigue al sistema salvo que se haya elegido "claro" con el botón,
   o se fuerza con data-theme="dark" (ver theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaef;
    --muted: #9aa2b1;
    --border: #2a2f3a;
    --accent: #46d9bb;
    --pos: #4cc38a;
    --neg: #ff7b72;
    --warn: #f0b75a;
    --chart-line: #7ea2ff;
    --chart-fill: rgba(126, 162, 255, 0.15);
    --c0: #7ea2ff;
    --c1: #4cc38a;
    --c2: #f0b75a;
    --c3: #d38cf0;
    --c4: #5fd0d6;
    --c5: #ff9f7a;
    --c6: #a8b0bf;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --text: #e8eaef;
  --muted: #9aa2b1;
  --border: #2a2f3a;
  --accent: #46d9bb;
  --pos: #4cc38a;
  --neg: #ff7b72;
  --warn: #f0b75a;
  --chart-line: #7ea2ff;
  --chart-fill: rgba(126, 162, 255, 0.15);
  --c0: #7ea2ff;
  --c1: #4cc38a;
  --c2: #f0b75a;
  --c3: #d38cf0;
  --c4: #5fd0d6;
  --c5: #ff9f7a;
  --c6: #a8b0bf;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 0.95rem; margin: 0; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  max-width: 1800px;
  margin: 0 auto;
}
.topbar p { margin: 4px 0 0; }
/* Logo de KryptOzone en la barra superior: una versión por tema. El fondo
   de cada imagen (blanco / negro) se funde con el de la página. */
.brand { margin: 0; line-height: 0; }
.brand-logo { height: 114px; width: auto; max-width: 100%; }
.brand-light { mix-blend-mode: multiply; }
.brand-dark { display: none; mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-light { display: none; }
  :root:not([data-theme="light"]) .brand-dark { display: inline; }
}
:root[data-theme="dark"] .brand-light { display: none; }
:root[data-theme="dark"] .brand-dark { display: inline; }
@media (max-width: 600px) { .brand-logo { height: 78px; } }

main { max-width: 1800px; margin: 0 auto; padding: 0 16px 32px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-right: 6px;
}

/* Luz verde de "Modo: Auto firma activa", con un pulso suave. */
.mode-light {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px 1px rgba(34, 197, 94, 0.8);
  vertical-align: 1px;
  animation: mode-light-pulse 2s ease-in-out infinite;
}
@keyframes mode-light-pulse {
  50% { box-shadow: 0 0 2px 0 rgba(34, 197, 94, 0.4); opacity: 0.75; }
}
@media (prefers-reduced-motion: reduce) { .mode-light { animation: none; } }

.banner { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.data-approvals { border: 1px solid var(--neg); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; background: color-mix(in srgb, var(--neg) 6%, transparent); }
.data-approvals h2 { font-size: 1rem; margin: 0 0 6px; color: var(--neg); }
.data-approval { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--neg) 25%, transparent); }
.data-approval .info { flex: 1 1 280px; min-width: 0; }
.data-approval .actions { display: flex; gap: 8px; }
.data-approval .state { font-weight: 600; }
.banner-error { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2 { color: var(--muted); font-weight: 500; }
.card .big { font-size: 1.6rem; font-weight: 650; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.card p { margin: 0; }
.card-main .big { font-size: 2rem; }

.panel { margin-bottom: 16px; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.panel-head p { margin: 0; }

.ranking-table { min-width: 1600px; }
.ranking-table-wrap { scrollbar-gutter: stable; }
.ranking-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ranking-scroll-hint, .ranking-cards { display: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; }
td.reason { white-space: normal; min-width: 220px; font-size: 0.82rem; color: var(--muted); }
tbody tr:last-child td { border-bottom: none; }
.empty td { color: var(--muted); text-align: center; padding: 16px; white-space: normal; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button {
  background: transparent;
  color: var(--text);
  border: none;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--brand-fill); color: var(--brand-ink); font-weight: 700; }

.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; }
.chart .area { fill: var(--chart-fill); }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 16px; }

button {
  font: inherit;
  font-weight: 600;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
}

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.login-card p { margin: 4px 0 16px; }
/* Logo animado de KryptOzone (login): arriba del cuadro de ingreso, más grande. */
.login-body { align-content: center; gap: 20px; }
.login-logo { width: min(640px, 100%); aspect-ratio: 16 / 9; background: #f8f8f8; border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.login-logo video, .login-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-logo img { display: none; }
/* El fondo del login es el del video de cada tema (#f8f8f8 en claro, negro en
   oscuro): el logo se funde con la página. */
.login-body { background: #f8f8f8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-body,
  :root:not([data-theme="light"]) .login-logo { background: #000; }
}
:root[data-theme="dark"] .login-body,
:root[data-theme="dark"] .login-logo { background: #000; }
.login-card h1 { margin-bottom: 16px; }
.login-card label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--brand-green);
  background: var(--brand-fill);
  color: var(--brand-ink);
  font-weight: 700;
  margin-top: 4px;
}
.login-error { color: var(--neg); }
.login-card button[type="submit"] { display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-card button[type="submit"] .spinner { border-color: color-mix(in srgb, var(--brand-ink) 25%, transparent); border-top-color: var(--brand-ink); }
.login-card button[type="submit"]:disabled { opacity: 0.8; cursor: progress; }
/* Detección del autocompletado del navegador (login.js escucha el animationstart). */
@keyframes bd-autofill { from { opacity: 1; } to { opacity: 1; } }
.login-card input:-webkit-autofill { animation: bd-autofill 1ms; }

.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; }
/* Más específica que .theme-switch (position: relative), que va después. */
.theme-switch.theme-corner { position: fixed; top: 16px; right: 16px; z-index: 10; }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.88rem;
  max-width: 180px;
}
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Interruptor sol / luna: la perilla tapa el ícono del modo inactivo. */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 62px;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.theme-switch .icon-sun { color: var(--warn); }
.theme-switch .icon-moon { color: var(--accent); }
.theme-switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
  transform: translateX(30px);
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(0); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .theme-switch .knob { transition: none; } }

.swatch.pos-swatch { background: var(--pos); }
.swatch.neg-swatch { background: var(--neg); }
.swatch.neutral-swatch { background: var(--c6); }
.legend-inline { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; }
.stats-chart { height: 200px; }
.bars-v .neutral-fill { fill: var(--c6); }
.bars-v .count-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.subhead { font-size: 0.82rem; font-weight: 500; color: var(--muted); margin: 14px 0 8px; }

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 16px;
}
.split > .panel { margin-bottom: 16px; }
.panel .split { margin-bottom: 8px; }

.fill-0 { fill: var(--c0); background: var(--c0); }
.fill-1 { fill: var(--c1); background: var(--c1); }
.fill-2 { fill: var(--c2); background: var(--c2); }
.fill-3 { fill: var(--c3); background: var(--c3); }
.fill-4 { fill: var(--c4); background: var(--c4); }
.fill-5 { fill: var(--c5); background: var(--c5); }
.fill-6 { fill: var(--c6); background: var(--c6); }

.pie-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.pie { width: 170px; height: 170px; flex: none; }
.pie svg { width: 100%; height: 100%; display: block; }
.pie .slice { stroke: var(--surface); stroke-width: 2; }
.pie .center-value { fill: var(--text); font-size: 15px; font-weight: 650; }
.pie .center-label { fill: var(--muted); font-size: 10px; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .label { flex: 1; }
.legend .value { font-variant-numeric: tabular-nums; color: var(--muted); }

.bars-h { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 175px) 1fr 64px; align-items: center; gap: 8px; font-size: 0.82rem; }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { position: relative; height: 14px; background: var(--surface-2); border-radius: 4px; }
.bar-track .zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.bar-track .bar { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar.pos-bg { background: var(--pos); }
.bar.neg-bg { background: var(--neg); }
.bar.blocked { opacity: 0.55; }

.bars-v { width: 100%; height: 160px; }
.bars-v svg { width: 100%; height: 100%; display: block; }
.bars-v .axis { fill: var(--muted); font-size: 11px; }
.bars-v .grid { stroke: var(--border); stroke-width: 1; }
.bars-v .pos-fill { fill: var(--pos); }
.bars-v .neg-fill { fill: var(--neg); }
.chart-empty.small-empty { font-size: 0.85rem; }

/* Posiciones activas */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--pos);
  vertical-align: middle;
  animation: pulse 2s ease-in-out infinite;
}
.live-dot.stale { background: var(--warn); animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

.dex-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dex-chips:empty { display: none; }
.dex-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.dex-uniswap_v3 { background: #7c3aed1f; border-color: #7c3aed66; color: #6d28d9; }
.dex-pancakeswap_v3 { background: #1fc7d41f; border-color: #1fc7d466; color: #0b8f99; }
:root[data-theme="dark"] .dex-uniswap_v3 { color: #c4b5fd; }
:root[data-theme="dark"] .dex-pancakeswap_v3 { color: #5fe0e8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dex-uniswap_v3 { color: #c4b5fd; }
  :root:not([data-theme="light"]) .dex-pancakeswap_v3 { color: #5fe0e8; }
}

/* Red blockchain (arriba de las tarjetas) -- deliberadamente neutro/gris,
   distinto de los colores por DEX (.dex-uniswap_v3, etc.) de cada tarjeta,
   para que no se lea como si repitiera la misma información. */
.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.network-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pos);
}

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.chip-pos { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.chip-neg { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.chip-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip-muted { background: var(--surface-2); color: var(--muted); }

.active-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.active-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }
.active-title h3 { margin: 0 0 6px; font-size: 1.05rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-note { margin: 4px 0; }

.range { margin: 14px 0 10px; }
.range-track { position: relative; height: 10px; border-radius: 5px; background: var(--border); }
.range-band { position: absolute; left: 8%; right: 8%; top: 0; bottom: 0; border-radius: 5px; background: color-mix(in srgb, var(--pos) 45%, transparent); }
.range-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--text);
}
.range-marker.out { background: var(--neg); }
.range-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-labels span:first-child { padding-left: 4%; }
.range-labels span:last-child { padding-right: 4%; }
.range-current { color: var(--text); text-align: center; }
.range-edge-pct { font-size: 0.9em; opacity: 0.75; }

.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.metric { display: flex; flex-direction: column; min-width: 0; }
.metric-wide { grid-column: 1 / -1; }
#networks-section .dex-chips { margin-bottom: 0; }
.metric-label { font-size: 0.75rem; color: var(--muted); }
.metric-value { font-variant-numeric: tabular-nums; font-weight: 600; overflow-wrap: anywhere; }
.metric-value-hl { font-size: 1.15em; }
.active-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.active-foot a { color: var(--accent); text-decoration: none; }
.active-foot a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .card .big { font-size: 1.35rem; }
  .card-main .big { font-size: 1.6rem; }
  .chart { height: 200px; }
}

@media (max-width: 1650px) {
  .ranking-scroll-hint { display: block; margin: 4px 0 8px; }
}

@media (max-width: 850px) {
  .ranking-table-wrap, .ranking-scroll-hint { display: none; }
  .ranking-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px; }
  .ranking-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); min-width: 0; }
  .ranking-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; }
  .ranking-card h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
  .ranking-card .badges { margin: 8px 0 12px; }
  .ranking-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .ranking-card-reason { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
  .ranking-cards .small-empty { padding: 20px; }
}

/* Lo oculto se oculta siempre, aunque la clase defina display (p. ej. .wallet-qr). */
[hidden] { display: none !important; }

/* Menús de la barra superior: billetera y autorizaciones (wallet.js) */
.menu { position: relative; }
.menu-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}
.menu-button[aria-expanded="true"] { border-color: var(--accent); }
.menu-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.menu-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-button.connected { border-color: color-mix(in srgb, var(--pos) 60%, var(--border)); }
.menu-button .mono { font-size: 0.8rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); }
.count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--neg);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 18px;
  text-align: center;
}
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: 320px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.menu-panel[hidden] { display: none; }
.menu-panel p { margin: 0; }
.menu-panel-wide { width: 460px; }
#wallet-panel { width: min(560px, calc(100vw - 32px)); }
@media (max-width: 600px) {
  .menu { position: static; }
  .menu-panel, .menu-panel-wide { position: fixed; left: 16px; right: 16px; top: 72px; width: auto; }
  #wallet-panel { width: auto; }
}
.wallet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button.primary { background: var(--brand-fill); color: var(--brand-ink); border: 1px solid var(--brand-green); padding: 6px 14px; font-weight: 700; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.wallet-qr { display: grid; justify-items: center; gap: 6px; }
.wallet-qr img { background: #fff; border-radius: 8px; padding: 8px; width: 260px; max-width: 100%; height: auto; }
.linklike { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
.auth-list { display: grid; gap: 12px; }
.auth-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); display: grid; gap: 6px; }
.auth-card h3 { margin: 0; font-size: 0.98rem; }
.auth-card ol { margin: 0; padding-left: 20px; }
.auth-card li.bad { color: var(--neg); }
.auth-status-pending { color: var(--warn); }
.auth-status-executed { color: var(--pos); }
.auth-status-failed, .auth-status-stale, .auth-status-cancelled { color: var(--neg); }
/* Identificador de la firma: en bloques de 4 para comparar con la billetera. */
.hash-box { border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 10px; background: var(--surface); display: grid; gap: 4px; }
.hash-label { font-size: 0.78rem; color: var(--muted); }
.hash-groups { display: flex; flex-wrap: wrap; gap: 3px 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; }
.hash-groups span:nth-child(odd) { color: var(--accent); }
.hash-groups span.edge { font-weight: 700; text-decoration: underline; }
.hash-quick { font-size: 0.8rem; }
.hash-quick b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.auth-card details summary { cursor: pointer; font-size: 0.82rem; color: var(--muted); }
.auth-history > summary { cursor: pointer; font-size: 0.82rem; color: var(--muted); }
/* Espera de la firma: reloj de carga + cuenta regresiva. */
.signing-wait { display: flex; align-items: center; gap: 8px; margin: 0; }
.signing-wait b { font-variant-numeric: tabular-nums; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Íconos de tokens */
.with-icon { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.token-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.token-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.token-icon-fallback { font-size: 0.6rem; font-weight: 700; color: var(--muted); }
.pair-icons { display: inline-flex; align-items: center; flex: none; }
.pair-icons .token-icon + .token-icon { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }
h3.with-icon .token-icon { width: 26px; height: 26px; }

/* Login con billetera */
.wallet-login { display: grid; gap: 10px; margin-top: 4px; }
.wallet-login > button { width: 100%; }
/* Botón de WalletConnect (logo oficial, como el de la marca) */
.wc-button { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 1rem; cursor: pointer; }

.wc-button:disabled { opacity: 0.6; cursor: progress; }
.wc-logo { width: 30px; height: 30px; flex: none; }
.wallet-login-caption { margin: -2px 0 0; text-align: center; font-size: 0.9rem; }
.login-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border, rgba(127, 127, 127, 0.3)); }

.wallet-login-consent { text-align: center; margin: 0; }
.wallet-login-consent a { color: inherit; text-decoration: underline; }
.wallet-login-security { margin: 0; padding: 8px 10px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, #3396ff 45%, transparent); background: color-mix(in srgb, #3396ff 8%, transparent); }

/* Términos y Privacidad */
.legal-body { background: var(--bg); color: var(--text); }
.legal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.legal-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.legal-brand img { border-radius: 8px; }
.legal-main { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; line-height: 1.6; }
.legal-main h1 { margin: 0 0 4px; font-size: 1.6rem; }
.legal-main h2 { margin: 36px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); scroll-margin-top: 72px; }
.legal-main section { scroll-margin-top: 72px; }
.legal-main h3 { margin: 20px 0 4px; font-size: 1.02rem; font-weight: 650; }
.legal-main h1 { font-weight: 700; }
.legal-main h2 { font-size: 1.3rem; font-weight: 700; }
.legal-main a { color: inherit; }
.legal-toc { margin: 12px 0 0; }

/* Opción de cuenta y ventana de llaves de acceso */
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-section { display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.user-section h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.95rem; }
.passkeys-list { display: grid; gap: 8px; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.passkey-row .info { min-width: 0; }
.passkey-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.passkey-add label { display: grid; gap: 4px; font-size: 0.85rem; }
.passkey-add input { min-width: 0; }

.wallet-login [role="status"]:empty { display: none; }

/* Panel de la billetera ordenado (red, dirección, rol) */
.wp-head { display: flex; align-items: center; gap: 8px; }
.wp-status { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.wp-status.on { background: var(--pos); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 25%, transparent); }
.wp-rows { display: grid; gap: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.wp-rows > div { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; padding: 8px 10px; }
.wp-rows > div + div { border-top: 1px solid var(--border); }
.wp-rows dt { color: var(--muted); font-size: 0.8rem; }
.wp-rows dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.wp-address { overflow-wrap: anywhere; }
.wallet-disconnected-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; padding: 16px 20px; border: 1px solid var(--warn); border-radius: var(--radius); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.wallet-disconnected-notice[hidden] { display: none; }
.wallet-disconnected-notice strong { color: var(--warn); }
.wallet-disconnected-notice p { margin: 4px 0 0; font-size: 0.9rem; }
.copy-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 4px; flex: none; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--accent); cursor: pointer; vertical-align: middle; }

.copy-icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copy-icon-button.copied { color: var(--pos); }
.wp-net { font-weight: 600; }
.net-icon { width: 18px; height: 16px; flex: none; }
.wallet-net { display: inline-flex; }
.wallet-net .net-icon { width: 15px; height: 13px; }
.wp-permissions { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; text-align: left; }
.wp-permissions:hover { border-color: var(--accent); }
.wp-permissions > span:first-of-type { flex: 1; }
.perm-badge { padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 650; }
.perm-badge.ok { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.perm-badge.missing { background: var(--neg); color: #fff; }
.perm-badge.warning { background: color-mix(in srgb, #f5a524 25%, transparent); color: #c27c00; }

/* Ventana de permisos del Safe */
.perm-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.perm-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.perm-inner { display: grid; gap: 10px; padding: 18px; }
.perm-inner p { margin: 0; }
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.perm-head h2 { margin: 0; font-size: 1.1rem; }
.perm-summary { font-weight: 600; }
.perm-summary.warn { color: #c27c00; }
.perm-body { display: grid; gap: 14px; }
.perm-group h3 { margin: 0 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.perm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.perm-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.perm-item.missing { border-color: color-mix(in srgb, var(--neg) 55%, var(--border)); background: color-mix(in srgb, var(--neg) 7%, transparent); }
.perm-item.warning, .perm-item.unknown { border-color: color-mix(in srgb, #f5a524 55%, var(--border)); }
.perm-text { display: grid; gap: 2px; min-width: 0; }
.perm-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 0.8rem; font-weight: 800; color: #fff; }
.perm-mark.ok, .perm-ok-mark { background: var(--pos); }
.perm-mark.missing, .perm-missing-mark { background: var(--neg); }
.perm-mark.warning, .perm-mark.unknown, .perm-warn-mark { background: #f5a524; }
.perm-ok-mark, .perm-missing-mark, .perm-warn-mark { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 0.65rem; font-weight: 800; }
.perm-impact.missing { color: var(--neg); }
.perm-impact.warning, .perm-impact.unknown { color: #c27c00; }
.perm-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.passkey-add input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }

.account-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; margin-top: 10px; }
.account-menu-item span { flex: 1; }
.passkeys-dialog .user-section { border: 0; padding: 0; gap: 14px; }
.passkeys-dialog .user-section[hidden] { display: none; }
.passkey-row { flex-wrap: wrap; }
.passkey-row .info { flex: 1 1 220px; overflow-wrap: anywhere; }
.passkey-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.passkey-edit { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; width: 100%; }
.passkey-edit[hidden] { display: none; }
.passkey-edit label { display: grid; gap: 4px; flex: 1 1 180px; }
.passkey-edit input { width: 100%; min-width: 0; }
.passkey-add label { flex: 1 1 180px; }
.passkeys-dialog input { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.passkeys-dialog [role="status"]:empty { display: none; }

.passkeys-dialog [hidden] { display: none; }

/* Botones de marca: verde turquesa del logo y detalles dorados. */
button.primary, .login-card button[type="submit"] {
  box-shadow: 0 3px 10px color-mix(in srgb, var(--brand-green) 20%, transparent);
}
.menu-button, .account-menu-item, .wc-button {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}
.account-menu-item > .icon:first-child { color: var(--accent); }
.account-menu-item > .icon:last-child { color: var(--muted); }
.menu-button .chevron { transition: transform 160ms ease; }
.menu-button[aria-expanded="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}
.theme-switch .icon-sun { color: var(--brand-gold); }
.passkey-button .wc-logo > rect { fill: var(--brand-green); }
.copy-icon-button { min-height: 30px; }
@media (hover: hover) {
  button:hover:not(:disabled) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
    transform: translateY(-1px);
  }
  button.primary:hover:not(:disabled), .login-card button[type="submit"]:hover:not(:disabled), .segmented button.active:hover:not(:disabled) {
    background: var(--brand-fill-hover);
    border-color: var(--brand-green);
    box-shadow: 0 5px 16px color-mix(in srgb, var(--brand-green) 30%, transparent);
  }
  .account-menu-item:hover:not(:disabled) > .icon:first-child { color: var(--brand-gold); }
  .segmented button:hover:not(:disabled) { transform: none; }
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand-gold) 20%, transparent);
}
button:active:not(:disabled) { transform: translateY(0); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.14); }
button:disabled { box-shadow: none; transform: none; }
@media (prefers-reduced-motion: reduce) {
  button, .menu-button .chevron { transition: none; }
  button:hover:not(:disabled), button:active:not(:disabled) { transform: none; }
}

/* Historial cerrado: columnas compactas y fichas en pantallas pequeñas. */
.closed-table-wrap { overflow: visible; }
.closed-table { table-layout: fixed; }
.closed-table th, .closed-table td { white-space: normal; overflow-wrap: anywhere; padding: 9px 5px; vertical-align: middle; }
.closed-table th { font-size: 0.72rem; }
.closed-table td { font-size: 0.81rem; }
/* 15 columnas, incluyendo la red: repartir el ancho sin scroll horizontal. */
.closed-table th:nth-child(1) { width: 10%; }
.closed-table th:nth-child(2) { width: 3%; text-align: center; }
.closed-table th:nth-child(3) { width: 5%; }
.closed-table th:nth-child(4) { width: 8.5%; }
.closed-table th:nth-child(5), .closed-table th:nth-child(6) { width: 7%; }
.closed-table th:nth-child(7) { width: 5.5%; }
.closed-table th:nth-child(8) { width: 7%; }
.closed-table th:nth-child(9) { width: 6.5%; }
.closed-table th:nth-child(10) { width: 6%; }
.closed-table th:nth-child(11) { width: 5.5%; }
.closed-table th:nth-child(12) { width: 10%; }
.closed-table th:nth-child(13) { width: 7%; }
.closed-table th:nth-child(14) { width: 5%; }
.closed-table th:nth-child(15) { width: 7%; }
.closed-table .with-icon { display: flex; flex-wrap: wrap; gap: 4px; }
.closed-range-edge { display: block; }
@media (max-width: 1200px) {
  .closed-table, .closed-table tbody { display: block; width: 100%; }
  .closed-table thead { display: none; }
  .closed-table tbody { display: grid; gap: 12px; }
  .closed-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--surface-2); }
  .closed-table td, .closed-table td.num { display: grid; gap: 4px; min-width: 0; padding: 8px; text-align: left; border: 0; font-size: 0.86rem; }
  .closed-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.73rem; font-weight: 500; }
  .closed-table td:first-child, .closed-table td:last-child { grid-column: 1 / -1; }
  .closed-table td:first-child { font-weight: 650; }
  .closed-table .empty td::before { content: none; }
}

.closed-date-line { display: block; white-space: nowrap; }

/* Control de Riesgo: campos y barras de reparto con paleta de marca. */
.risk-dialog { width: min(660px, calc(100vw - 32px)); }
#risk-form { display: grid; gap: 18px; }
.risk-section { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.risk-distribution-section { border-bottom: 2px solid var(--brand-gold); }
.risk-section h3 { margin: 0; font-size: 0.95rem; }
.risk-section label { display: grid; gap: 5px; font-size: 0.88rem; min-width: 0; }
.risk-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0; }
.risk-fields:disabled { opacity: 0.5; }
.risk-dialog input:not([type="checkbox"]):not([type="range"]), .risk-dialog select { width: 100%; min-width: 0; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.risk-dialog :is(input, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.risk-section .risk-toggle { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 650; }
.risk-toggle input { width: 20px; height: 20px; accent-color: var(--brand-green); }
.risk-allocations { display: grid; gap: 12px; }
.risk-allocation { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.risk-allocation output { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.risk-allocation input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 4px 0; height: 24px; cursor: pointer; accent-color: var(--brand-green); }
.risk-allocation input:disabled { cursor: default; opacity: 0.45; }
.risk-allocation-note { grid-column: 1 / -1; margin: 0; }
.risk-allocation-assign { grid-column: 1 / -1; justify-self: end; }
.risk-total { color: var(--accent); font-weight: 650; }
#risk-state:empty { display: none; }
@media (max-width: 480px) { .risk-fields { grid-template-columns: minmax(0, 1fr); } }

.risk-mode-switch { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; font-weight: 650; }
.risk-mode-switch input { appearance: none; width: 52px; height: 30px; border: 1px solid var(--brand-green); border-radius: 20px; background: var(--surface-2); position: relative; cursor: pointer; flex-shrink: 0; }
.risk-mode-switch input::before { content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-gold); left: 3px; top: 3px; transition: transform 150ms ease; }
.risk-mode-switch input:checked { background: var(--brand-green); }
.risk-mode-switch input:checked::before { transform: translateX(22px); background: #052e26; }
.risk-suggested-ranges { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.risk-suggested-ranges p { margin: 4px 0; }
@media (prefers-reduced-motion: reduce) { .risk-mode-switch input::before { transition: none; } }

/* Dona compacta del resultado cerrado: verde ganadas, rojo perdidas. */
.closed-results-chart { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.closed-results-chart .pie { width: 104px; height: 104px; }
.closed-results-chart .center-value { font-size: 28px; }
.closed-results-chart .center-label { font-size: 18px; }
.closed-results-chart .slice { stroke-width: 4; stroke-linejoin: round; }
.closed-results-chart .legend { min-width: 0; font-size: 0.75rem; }
.closed-results-chart .legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 6px 0; }
.closed-results-chart .legend .value { color: var(--text); font-weight: 650; }
.closed-results-chart .legend .label { line-height: 1.5; }
.closed-results-chart .result-win { fill: var(--pos); background: var(--pos); }
.closed-results-chart .result-loss { fill: var(--neg); background: var(--neg); }
.closed-results-chart .result-flat { fill: var(--muted); background: var(--muted); }
.closed-results-chart .result-unknown { fill: var(--brand-gold); background: var(--brand-gold); }
.card .closed-results-caption { margin-top: 8px; font-size: 0.7rem; }
.closed-results-chart .chart-empty { height: 88px; padding: 0; font-size: 0.7rem; }

/* Cuatro cuadros de resumen, con detalle legible y espacio equilibrado. */
.summary-card { display: flex; flex-direction: column; min-width: 0; padding: 18px; gap: 8px; box-shadow: 0 4px 16px color-mix(in srgb, var(--text) 4%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--brand-green) 3%, var(--surface)), var(--surface)); }
.summary-card.card-main { border-color: color-mix(in srgb, var(--brand-green) 35%, var(--border)); background: linear-gradient(145deg, color-mix(in srgb, var(--brand-green) 7%, var(--surface)), var(--surface)); }
.summary-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.summary-card-head h2 { margin: 0; color: var(--text); font-weight: 600; font-size: 0.92rem; }
.summary-card-icon { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; color: var(--accent); background: color-mix(in srgb, var(--brand-green) 10%, var(--surface)); }
.summary-results .summary-card-icon, .summary-networks .summary-card-icon { color: var(--warn); background: color-mix(in srgb, var(--brand-gold) 12%, var(--surface)); }
.summary-card .big { font-size: clamp(1.6rem, 2vw, 2rem); line-height: 1.15; margin: 0; }
.summary-description { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.summary-breakdown { margin: 6px 0 0; padding: 10px 12px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; font-size: 0.8rem; }
.summary-breakdown > div { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.summary-breakdown dt { color: var(--muted); }
.summary-breakdown dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary-address { margin-top: auto; padding-top: 8px; }
.summary-address .mono { font-size: 0.73rem; line-height: 1.5; overflow-wrap: anywhere; margin-top: 3px; color: var(--muted); }
.summary-card .summary-warning:empty { display: none; }
.summary-card-footer { margin-top: auto !important; padding-top: 10px; font-size: 0.78rem; line-height: 1.5; color: var(--muted); }
.summary-capital-meter { width: 100%; height: 9px; border: 0; background: var(--surface-2); border-radius: 8px; }
.summary-capital-meter::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 8px; }
.summary-capital-meter::-webkit-meter-optimum-value { background: var(--brand-green); border-radius: 8px; }
.summary-capital-meter::-moz-meter-bar { background: var(--brand-green); border-radius: 8px; }
.summary-results .closed-results-chart { margin-top: 2px; }
.summary-results .closed-results-caption { margin-top: 0; }
.summary-networks .dex-chips { margin-top: 8px; }
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cards { grid-template-columns: minmax(0, 1fr); } .summary-card { padding: 16px; } }

.risk-balance { font-weight: 650; color: var(--accent); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.risk-allocation-amount { grid-column: 1 / -1; margin: 0; font-size: 0.86rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--pos); }

.risk-reserve { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--brand-gold); border-radius: 12px; background: var(--surface-2); }
.risk-reserve > label:first-child { display: flex; justify-content: space-between; gap: 12px; font-weight: 650; }
.risk-reserve output { color: var(--brand-gold); }
.risk-reserve input[type="range"] { width: 100%; height: 24px; margin: 0; accent-color: var(--brand-gold); }
.risk-reserve p { margin: 0; }

/* Acceso y documentos legales: tarjeta centrada y colores de la marca. */
.login-body { min-height: 100svh; padding: 56px 20px 32px; gap: 0; background: radial-gradient(ellipse at 15% 15%, color-mix(in srgb, var(--brand-green) 10%, transparent), transparent 52%), radial-gradient(ellipse at 90% 90%, color-mix(in srgb, var(--brand-gold) 8%, transparent), transparent 48%), var(--bg); }
:root[data-theme="dark"] .login-body { background: radial-gradient(ellipse at 15% 15%, #00b99b14, transparent 52%), radial-gradient(ellipse at 90% 90%, #f5bd3910, transparent 48%), var(--bg); }
.login-card { max-width: 440px; padding: 24px 32px 28px; border-radius: 24px; border-color: color-mix(in srgb, var(--brand-green) 25%, var(--border)); box-shadow: 0 24px 70px #0002, 0 3px 12px #0001; position: relative; overflow: hidden; }
.login-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--brand-green), var(--brand-gold)); }
.login-heading { text-align: center; margin-bottom: 24px; }
.login-card .login-logo { width: min(220px, 100%); margin: 0 auto 4px; border-radius: 16px; }
.login-card h1 { margin: 0; font-size: clamp(1.6rem, 5vw, 1.9rem); letter-spacing: -0.04em; }
.login-card .login-intro { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; }
.login-card label { margin-bottom: 16px; font-weight: 550; }
.login-card input { min-height: 46px; margin-top: 7px; border-radius: 11px; padding: 11px 13px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.login-card input:focus-visible { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-green) 18%, transparent); }
.login-card #login-code { letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }
.login-card #login-submit { min-height: 48px; border-radius: 12px; font-size: 1rem; }
.login-card .wallet-login { margin-top: 18px; gap: 12px; }
.login-card .passkey-button { min-height: 52px; border-radius: 12px; }
.login-card .wallet-login-caption { margin: 0; color: var(--muted); font-size: 0.82rem; }
.login-card .login-error:not([hidden]) { padding: 12px; border: 1px solid color-mix(in srgb, var(--neg) 35%, var(--border)); background: color-mix(in srgb, var(--neg) 8%, var(--surface)); border-radius: 10px; font-size: 0.88rem; }
.login-legal { display: flex; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.login-legal a { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1; min-height: 40px; padding: 8px 6px; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 0.78rem; }
.login-legal .icon { width: 17px; height: 17px; color: var(--brand-gold); flex-shrink: 0; }
.login-legal a:focus-visible, .legal-toc a:focus-visible, .legal-back:focus-visible { outline: 2px solid var(--brand-green); outline-offset: 3px; }
.legal-header { padding: 16px max(20px, calc((100vw - 920px) / 2)); border-bottom-color: color-mix(in srgb, var(--brand-gold) 45%, var(--border)); }
.legal-main { max-width: 920px; padding: 40px 20px 60px; }
.legal-hero { text-align: center; padding: 36px 24px; background: linear-gradient(135deg, color-mix(in srgb, var(--brand-green) 7%, var(--surface)), var(--surface)); border: 1px solid var(--border); border-radius: 22px; }
.legal-main .legal-eyebrow { display: inline-block; margin: 0 0 14px; padding: 5px 12px; border-radius: 99px; background: color-mix(in srgb, var(--brand-gold) 12%, var(--surface)); color: var(--text); font-size: 0.76rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.legal-main h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -0.035em; line-height: 1.2; }
.legal-hero > .muted { font-size: 0.88rem; margin: 14px 0 0; }
.legal-toc { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.legal-toc a, .legal-back { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 18px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--brand-green) 35%, var(--border)); text-decoration: none; font-size: 0.9rem; font-weight: 600; background: var(--surface-2); }
.legal-main section { margin-top: 24px; padding: 26px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 24px #00000008; scroll-margin-top: 100px; }
.legal-main h2 { margin: 0 0 20px; padding: 0 0 14px; border-top: none; border-bottom: 2px solid color-mix(in srgb, var(--brand-gold) 65%, var(--border)); font-size: 1.3rem; }
.legal-main ul { padding: 0; margin: 0; list-style: none; display: grid; gap: 18px; }
.legal-main li { position: relative; padding-left: 20px; color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.legal-main li::before { content: ''; position: absolute; left: 0; top: 0.7em; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-green); }
.legal-main li strong { color: var(--text); font-weight: 650; }
.legal-back { margin-top: 24px; color: var(--text); }
@media (hover: hover) {
  .login-legal a:hover, .legal-toc a:hover, .legal-back:hover { border-color: var(--brand-green); color: var(--text); background: color-mix(in srgb, var(--brand-green) 8%, var(--surface)); box-shadow: 0 3px 12px color-mix(in srgb, var(--brand-green) 12%, transparent); }
}
@media (max-width: 480px) {
  .login-body { padding: 64px 16px 24px; }
  .login-card { padding: 20px; border-radius: 20px; }
  .login-card .login-logo { width: 180px; }
  .legal-main { padding: 24px 16px 40px; }
  .legal-hero { padding: 28px 18px; }
  .legal-main section { padding: 20px; scroll-margin-top: 135px; }
}
@media (prefers-reduced-motion: reduce) { .login-card input { transition: none; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-body { background: radial-gradient(ellipse at 15% 15%, #00b99b14, transparent 52%), radial-gradient(ellipse at 90% 90%, #f5bd3910, transparent 48%), var(--bg); }
}

.reserve-apply { justify-self: end; min-height: 42px; padding: 10px 24px; border: 1px solid var(--brand-gold); border-radius: 10px; background: var(--brand-gold); color: var(--brand-ink); font-weight: 700; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-gold) 16%, transparent); }
.reserve-apply:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 3px; }
.reserve-apply:disabled { opacity: 0.5; }
@media (hover: hover) { .reserve-apply:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-gold) 85%, white); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-gold) 28%, transparent); } }

/* Identidad estática Kz / árbol DeFi: versiones originales por tema. */
.login-card .login-kz { width: 150px; aspect-ratio: 1; background: transparent; cursor: default; overflow: visible; margin-bottom: 18px; }
.login-kz img { width: 100%; height: 100%; object-fit: contain; }
.login-kz .brand-light { display: block; }
.login-kz .brand-dark { display: none; }
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px 24px; }
.panel-yield-brand { grid-column: 1; grid-row: 1; width: min(300px, 100%); min-width: 0; }
.panel-yield-brand img { display: block; width: 100%; height: auto; object-fit: contain; }
.panel-brand-center { grid-column: 2; grid-row: 1; justify-self: center; display: flex; align-items: center; gap: 12px; }
.panel-kz { display: block; width: 96px; flex: 0 0 96px; }
.panel-kz img { width: 100%; height: auto; object-fit: contain; }
.panel-wordmark { display: block; width: 220px; }
.panel-wordmark img { width: 100%; height: auto; object-fit: contain; }
.topbar-meta { grid-column: 1; grid-row: 2; min-width: 0; }
.topbar .topbar-actions { grid-column: 2 / -1; grid-row: 2; min-width: 0; }
.panel-yield-brand .brand-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-kz .brand-light, :root:not([data-theme="light"]) .panel-yield-brand .brand-light { display: none; }
  :root:not([data-theme="light"]) .login-kz .brand-dark, :root:not([data-theme="light"]) .panel-yield-brand .brand-dark { display: block; }
}
:root[data-theme="dark"] .login-kz .brand-light, :root[data-theme="dark"] .panel-yield-brand .brand-light { display: none; }
:root[data-theme="dark"] .login-kz .brand-dark, :root[data-theme="dark"] .panel-yield-brand .brand-dark { display: block; }
@media (max-width: 1050px) {
  .topbar-meta { grid-column: 1 / -1; }
  .topbar .topbar-actions { grid-column: 1 / -1; grid-row: 3; }
}
@media (max-width: 600px) {
  .topbar { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .panel-yield-brand { grid-column: 1; grid-row: 1; justify-self: center; width: 240px; }
  .panel-brand-center { grid-column: 1; grid-row: 2; }
  .panel-kz { width: 78px; flex-basis: 78px; }
  .panel-wordmark { width: 190px; }
  .topbar-meta { grid-column: 1; grid-row: 3; text-align: center; }
  .topbar .topbar-actions { grid-column: 1; grid-row: 4; justify-content: center; }
  .login-card .login-kz { width: 130px; }
}

:root .login-card .login-kz { background: transparent; }

#wallet-button:disabled { opacity: 1; cursor: default; }
#wallet-button:disabled .chevron { display: none; }

#wallet-connect, #wallet-notice-connect { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.walletconnect-logo { width: 24px; height: 18px; flex: none; fill: currentColor; }

.unavailable-fill { fill: var(--muted); opacity: .5; }

.network-logo { display: inline-block; width: 26px; height: 26px; flex: none; vertical-align: middle; }
.network-pill { display: inline-flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--brand-green) 35%, var(--border)); border-radius: 12px; background: color-mix(in srgb, var(--brand-green) 7%, var(--surface-2)); color: var(--text); box-shadow: 0 3px 9px rgba(0,0,0,.1); transition: border-color .2s, background .2s, box-shadow .2s; }
.network-pill-name { font-weight: 650; font-size: .95rem; }
.network-pill-count { padding: 4px 8px; border-radius: 7px; font-size: .78rem; font-weight: 650; color: var(--brand-green); background: color-mix(in srgb, var(--brand-green) 12%, transparent); }
.summary-networks .dex-chips { margin-top: 8px; gap: 8px; }
.closed-network-cell { text-align: center; }
.closed-network-cell .network-logo { width: 23px; height: 23px; }
@media (hover: hover) { .network-pill:hover { border-color: var(--brand-green); background: color-mix(in srgb, var(--brand-green) 12%, var(--surface-2)); box-shadow: 0 5px 15px rgba(0,0,0,.15); } }
@media (max-width: 1200px) { .closed-network-cell { text-align: left; } }

.closed-results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 12px; margin-top: 4px; align-items: start; }
.closed-result-group { min-width: 0; padding: 12px 8px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.closed-result-title { margin: 0 0 8px; font-size: .75rem; font-weight: 650; color: var(--muted); text-align: center; }
.closed-network-results { display: grid; gap: 14px; min-width: 0; }
.closed-results-grid .closed-results-chart { flex-direction: column; gap: 8px; margin-top: 0; }
.closed-results-grid .closed-results-chart .legend { display: grid; justify-items: center; width: fit-content; max-width: 100%; flex: none; align-self: center; margin-top: 2px; }
.closed-results-grid .closed-results-chart .legend li { grid-template-columns: 10px minmax(0, 1fr); width: fit-content; max-width: 100%; gap: 5px; padding: 3px 0; }
.closed-results-grid .closed-results-chart .legend .label { text-align: center; }
.closed-results-grid .closed-results-chart .center-label { font-size: 15px; }
.closed-results-grid .closed-results-chart .donut-network-logo { width: 40px; height: 40px; }
@media (max-width: 360px) { .closed-results-grid { gap: 8px; } .closed-results-grid .legend { font-size: .7rem; } }

.chart { position: relative; }
.chart-tooltip { position: absolute; z-index: 3; pointer-events: none; max-width: min(290px, calc(100% - 16px)); padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--chart-line) 50%, var(--border)); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: .78rem; line-height: 1.5; }
.chart-tooltip-date { color: var(--muted); font-size: .72rem; margin-bottom: 4px; }
.chart-tooltip-balance { display: block; font-size: .87rem; }
.chart-tooltip-detail { color: var(--muted); font-size: .7rem; margin-top: 3px; }
.chart .chart-hover-guide { stroke: var(--chart-line); stroke-width: 1; stroke-dasharray: 4 4; opacity: .6; pointer-events: none; }
.chart .chart-hover-dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart-inspect-area { cursor: crosshair; touch-action: pan-y; }
.chart-inspect-area:focus-visible { outline: none; stroke: var(--chart-line); stroke-width: 1; }

.summary-breakdown > div + div { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.pool-network-capital { margin-top: 5px; }
.pool-network-capital > p { font-size: .74rem; margin: 0 0 6px; }
.pool-network-breakdown { margin-top: 0; }
.pool-network-breakdown > div { align-items: center; }
.pool-network-name { display: inline-flex; align-items: center; gap: 8px; }
.pool-network-name .network-logo { width: 23px; height: 23px; }

.composition-note { margin: 0 0 12px; }
.composition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }
#composition-networks { display: contents; }
.composition-group { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.composition-group h3 { font-size: .87rem; font-weight: 650; margin: 0 0 12px; }
.composition-network-heading { display: flex; align-items: center; gap: 8px; }
.composition-pie-wrap { gap: 12px; justify-content: center; }
.composition-pie-wrap .pie { width: 140px; height: 140px; }
.composition-pie-wrap .legend { min-width: min(100%, 200px); font-size: .75rem; }
.composition-pie-wrap .legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; padding: 6px 0; gap: 6px; }
@supports (grid-template-columns: subgrid) {
  .composition-pie-wrap .legend { display: grid; grid-template-columns: 10px minmax(0, 1fr) max-content; column-gap: 6px; }
  .composition-pie-wrap .legend li { grid-column: 1 / -1; grid-template-columns: subgrid; }
}
.composition-pie-wrap .legend .label { min-width: 0; line-height: 1.4; }
.composition-pie-wrap .legend .value { margin-left: 0; text-align: right; white-space: nowrap; font-size: .7rem; }
.composition-pie-wrap .composition-total-legend { min-width: min(100%, 280px); }
.composition-token-label { display: grid; grid-template-columns: minmax(0, 1fr) 59px; align-items: center; gap: 8px; }
.composition-token-name { min-width: 0; overflow-wrap: anywhere; }
.composition-network-icons { display: grid; grid-template-columns: repeat(3, 17px); align-items: center; gap: 4px; }
.composition-network-icons .network-logo { width: 17px; height: 17px; }
.pie .donut-network-logo { width: 40px; height: 40px; }

/* Confirmación de preferencias con verificación renovada de identidad. */
.confirmation-card { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); gap: 14px; }
.confirmation-heading { display: flex; align-items: center; gap: 12px; }
.confirmation-heading > span { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; color: #12c9a7; background: rgba(18,201,167,.12); font-weight: 750; }
.confirmation-card p { margin: 0; line-height: 1.55; }
.confirmation-card .risk-fields[hidden] { display: none; }
.risk-dialog .perm-foot { padding-top: 4px; }
@media (max-width: 480px) { .risk-dialog .perm-foot .primary { flex: 1; } .confirmation-card { padding: 14px; } }
