/* ═══════════════════════════════════════════════════════
   CRYPTO PORTFOLIO PRO — REDESIGN v2
   Aesthetic: Bloomberg Terminal · Operator · Refined Dark
   ═══════════════════════════════════════════════════════ */

/* Las fuentes se cargan desde index.html con preload no bloqueante;
   no usar @import aquí (duplicaba la descarga y bloqueaba el render). */

:root {
  color-scheme: dark;

  /* Core palette — deep navy + electric green terminal */
  --bg:             #050d14;
  --bg-2:           #080f18;
  --bg-3:           #0b1520;
  --panel:          rgba(8, 16, 26, 0.92);
  --panel-strong:   rgba(6, 13, 22, 0.98);
  --panel-soft:     rgba(255, 255, 255, 0.032);
  --panel-hover:    rgba(255, 255, 255, 0.055);
  --line:           rgba(64, 120, 172, 0.18);
  --line-strong:    rgba(64, 120, 172, 0.30);
  --line-accent:    rgba(83, 211, 162, 0.22);

  /* Typography */
  --text:           #e8f2ff;
  --text-2:         #c2d5e8;
  --muted:          #6d8fa8;
  --muted-2:        #4a6478;

  /* Signal colors — saturated & precise */
  --accent:         #3effa8;
  --accent-dim:     rgba(62, 255, 168, 0.12);
  --accent-2:       #5aabff;
  --accent-2-dim:   rgba(90, 171, 255, 0.12);
  --danger:         #ff6b6b;
  --warning:        #ffc947;
  --positive:       #3effa8;
  --negative:       #ff5555;
  --neutral:        #6d9ec4;
  --positive-bg:    rgba(62, 255, 168, 0.08);
  --negative-bg:    rgba(255, 85, 85, 0.08);
  --warning-bg:     rgba(255, 201, 71, 0.08);

  /* Glows */
  --glow-accent:    0 0 24px rgba(62, 255, 168, 0.14);
  --glow-blue:      0 0 24px rgba(90, 171, 255, 0.14);

  /* Structure */
  --shadow:         0 32px 80px rgba(1, 6, 14, 0.5);
  --shadow-sm:      0 8px 28px rgba(1, 6, 14, 0.3);
  --radius-xl:      24px;
  --radius-lg:      18px;
  --radius-md:      14px;
  --radius-sm:      10px;
  --radius-xs:      7px;

  /* Typography scale */
  --font-display:   'Space Mono', 'Courier New', monospace;
  --font-body:      'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono:      'Space Mono', 'Courier New', monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:             #f0f4f8;
  --bg-2:           #e4ecf4;
  --bg-3:           #d8e5f0;
  --panel:          rgba(255, 255, 255, 0.92);
  --panel-strong:   rgba(255, 255, 255, 0.98);
  --panel-soft:     rgba(10, 28, 50, 0.04);
  --panel-hover:    rgba(10, 28, 50, 0.07);
  --line:           rgba(30, 70, 110, 0.12);
  --line-strong:    rgba(30, 70, 110, 0.20);
  --line-accent:    rgba(0, 140, 80, 0.18);
  --text:           #0d1f30;
  --text-2:         #243547;
  --muted:          #5a7a92;
  --muted-2:        #8aabbd;
  --accent:         #00895e;
  --accent-dim:     rgba(0, 137, 94, 0.1);
  --accent-2:       #1a6ec7;
  --accent-2-dim:   rgba(26, 110, 199, 0.1);
  --danger:         #c94040;
  --warning:        #a86800;
  --positive:       #007a50;
  --negative:       #c73030;
  --neutral:        #4a7090;
  --positive-bg:    rgba(0, 122, 80, 0.07);
  --negative-bg:    rgba(199, 48, 48, 0.07);
  --warning-bg:     rgba(168, 104, 0, 0.08);
  --glow-accent:    0 0 0 transparent;
  --glow-blue:      0 0 0 transparent;
  --shadow:         0 20px 60px rgba(14, 40, 70, 0.1);
  --shadow-sm:      0 4px 18px rgba(14, 40, 70, 0.08);
}

/* ── Reset & Base ── */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 8% 5%, rgba(90, 171, 255, 0.09), transparent),
    radial-gradient(ellipse 50% 30% at 90% 8%, rgba(62, 255, 168, 0.07), transparent),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(5, 15, 30, 0.8), transparent);
  overflow-x: hidden;
}

/* Grid texture — very subtle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(62, 255, 168, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62, 255, 168, 0.018) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: linear-gradient(180deg, rgba(255,255,255,0.6) 0%, transparent 75%);
}

/* Scanlines aesthetic overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.015) 2px,
    rgba(0, 0, 0, 0.015) 4px
  );
}

h1, h2, h3, h4, p { margin: 0; }

h1, h2, h3 {
  font-family: var(--font-body);
  letter-spacing: -0.04em;
  font-weight: 700;
}

button, input, select { font: inherit; }

/* ── App Shell ── */

.app-shell {
  position: relative;
  z-index: 1;
  width: calc(100% - 24px);
  max-width: 1960px;
  margin: 0 auto;
  padding: 14px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Sticky top bar ── */
.sticky-bar {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 60;
  width: min(1100px, calc(100% - 28px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-accent);
  background: rgba(5, 13, 22, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(62, 255, 168, 0.1) inset;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 0.25s, transform 0.25s;
}

.sticky-bar.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.sticky-bar-title {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 32ch;
}

.sticky-bar-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
}

.sticky-bar-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.sticky-bar-pnl {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}
.sticky-bar-pnl.positive { color: var(--positive); background: var(--positive-bg); }
.sticky-bar-pnl.negative { color: var(--negative); background: var(--negative-bg); }

.sticky-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.sticky-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Panels & Cards ── */

.hero-panel,
.panel,
.summary-card,
.chart-card,
.activity-item {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr);
  gap: 28px;
  padding: 32px 36px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border-color: var(--line-accent);
  background:
    radial-gradient(ellipse 60% 80% at 100% 0%, rgba(62, 255, 168, 0.08), transparent 55%),
    radial-gradient(ellipse 40% 50% at 0% 100%, rgba(90, 171, 255, 0.06), transparent 60%),
    linear-gradient(160deg, rgba(8, 18, 30, 0.97), rgba(6, 13, 22, 0.98));
}

/* Decorative corner accent */
.hero-panel::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(62, 255, 168, 0.12) 0%, transparent 65%);
  pointer-events: none;
}

:root[data-theme="light"] .hero-panel {
  background:
    radial-gradient(ellipse 55% 70% at 100% 0%, rgba(0, 137, 94, 0.1), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(245, 250, 255, 0.96));
  border-color: rgba(0, 137, 94, 0.18);
}

.panel {
  border-radius: var(--radius-xl);
  padding: 28px;
}

/* ── Eyebrow / Labels ── */

.eyebrow,
.status-label,
.inline-field span,
.th-button,
.tooltip-dot,
.chart-chip {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent);
}

.eyebrow { color: var(--accent); }

/* ── Hero copy ── */

.hero-copy {
  max-width: 820px;
}

.hero-copy h1 {
  margin-top: 10px;
  font-size: clamp(2.4rem, 4.5vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

:root[data-theme="light"] .hero-copy h1 {
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.portfolio-name-display {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: clamp(0.85rem, 1.8vw, 1.05rem);
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.portfolio-name-display::before {
  content: "▶";
  font-size: 0.6em;
  color: var(--accent);
}

.hero-text,
.panel-copy,
.info-grid p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ── Hero side ── */

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Fields ── */

.inline-field {
  position: relative;
  flex: 1;
  min-width: 150px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(64, 120, 172, 0.22);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s;
}

.inline-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(62, 255, 168, 0.08);
}

.inline-field span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.inline-field-wide {
  min-width: 240px;
  flex: 1.4;
}

.inline-input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(64, 120, 172, 0.18);
  background: rgba(5, 12, 22, 0.8);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.inline-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(62, 255, 168, 0.1);
}

.inline-input::placeholder { color: var(--muted-2); }

select,
.table-input,
.primary-btn,
.ghost-btn,
.danger-btn,
.flag-btn,
.icon-btn,
.th-sort-btn {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

select,
.table-input,
.ghost-btn,
.danger-btn,
.flag-btn,
.icon-btn,
.th-sort-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 42px;
  padding: 0 42px 0 12px;
  border-radius: var(--radius-sm);
  border-color: rgba(64, 120, 172, 0.18);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236d8fa8'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(8, 18, 30, 0.88), rgba(5, 12, 22, 0.94));
  background-position: calc(100% - 14px) center, center;
  background-size: 10px 6px, 100% 100%;
  background-repeat: no-repeat;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.15s;
}

select:hover,
select:focus {
  border-color: rgba(62, 255, 168, 0.30);
  outline: none;
}

select option {
  color: var(--text);
  background: #0b1520;
}

:root[data-theme="light"] select {
  color-scheme: light;
  border-color: rgba(30, 70, 110, 0.16);
  background-color: rgba(255, 255, 255, 0.98);
  color: var(--text);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a7a92'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(242,248,254,0.96));
}

:root[data-theme="light"] select option,
:root[data-theme="light"] select optgroup {
  background: #ffffff;
  color: #0d1f30;
}

:root[data-theme="light"] #currencySelect,
:root[data-theme="light"] #autoRefreshSelect {
  color-scheme: light;
  background-color: #ffffff;
  color: #0d1f30;
  border-color: rgba(30, 70, 110, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

:root[data-theme="light"] #currencySelect:hover,
:root[data-theme="light"] #currencySelect:focus,
:root[data-theme="light"] #autoRefreshSelect:hover,
:root[data-theme="light"] #autoRefreshSelect:focus {
  color: #0d1f30;
  border-color: rgba(0, 140, 80, 0.28);
  background-color: #ffffff;
}

:root[data-theme="light"] .inline-input {
  border-color: rgba(30, 70, 110, 0.16);
  background: rgba(255, 255, 255, 0.9);
}

:root[data-theme="light"] .inline-field {
  border-color: rgba(30, 70, 110, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

/* ── Buttons ── */

.primary-btn,
.ghost-btn,
.danger-btn,
.flag-btn,
.icon-btn,
.th-sort-btn {
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease,
              color 130ms ease, box-shadow 130ms ease;
}

.primary-btn {
  border: 1px solid rgba(62, 255, 168, 0.4);
  font-weight: 700;
  color: #030d0a;
  background: linear-gradient(135deg, #3effa8, #22d98a);
  box-shadow: 0 0 20px rgba(62, 255, 168, 0.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(62, 255, 168, 0.28);
  background: linear-gradient(135deg, #5affb8, #3effa8);
}

.ghost-btn {
  border-color: var(--line);
  font-weight: 600;
}

.ghost-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.danger-btn {
  background: rgba(255, 85, 85, 0.1);
  border-color: rgba(255, 85, 85, 0.25);
  color: #ffb8b8;
}

.danger-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 85, 85, 0.18);
  border-color: rgba(255, 85, 85, 0.4);
}

/* ── Status cards ── */

.status-card {
  flex: 1;
  min-width: 200px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.status-card strong {
  font-family: var(--font-mono);
  display: block;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.status-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Summary grid ── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.summary-card:hover::before { opacity: 1; }
.summary-card:hover { transform: translateY(-2px); border-color: var(--line-accent); }

.summary-card span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  color: var(--muted);
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.summary-card p {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.summary-card.positive strong { color: var(--positive); }
.summary-card.negative strong { color: var(--negative); }
.summary-card.warning strong  { color: var(--warning); }

/* ── Panel headings ── */

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-heading h2 {
  margin-top: 8px;
  font-size: clamp(1.1rem, 2.4vw, 1.55rem);
  font-weight: 700;
}

/* ── Toolbar ── */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-group-end {
  justify-content: flex-end;
}

/* ── Controls panel ── */

.controls-panel {
  padding: 16px 22px;
}

/* ── Charts ── */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 16px;
}

.chart-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.chart-head h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
}

.chart-head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-chip {
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.chart-stage {
  position: relative;
  height: 240px;
}

.chart-range-control {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.range-chip {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}

.range-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.range-chip.is-active {
  border-color: var(--accent);
  background: rgba(62, 255, 168, 0.1);
  color: var(--accent);
}

/* ── Table ── */

.table-panel-full {
  padding: 28px;
}

.table-wrap {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: visible;
  background: rgba(255, 255, 255, 0.01);
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 13, 24, 0.96);
  backdrop-filter: blur(8px);
  text-align: center;
  white-space: normal;
}

:root[data-theme="light"] th {
  background: rgba(250, 253, 255, 0.96);
}

th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.th-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  text-align: center;
}

.th-sort-btn {
  background: none;
  border: none;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  min-height: auto;
}

.th-sort-btn:hover {
  color: var(--text);
  background: var(--panel-soft);
  transform: none;
  border-color: transparent;
}

.th-sort-btn.is-active {
  color: var(--accent);
}

.th-button {
  padding: 5px 8px;
  color: var(--muted);
}

/* Tooltip */
.tooltip-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 0.6rem;
  cursor: help;
  color: var(--muted);
  flex-shrink: 0;
  position: relative;
}

.tooltip-dot::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

.tooltip-dot:hover::after,
.tooltip-dot:focus::after {
  opacity: 1;
}

/* Table rows */
td {
  padding: 8px;
  border-bottom: 1px solid rgba(64, 120, 172, 0.1);
  vertical-align: middle;
  text-align: center;
  min-width: 0;
}

tr:last-child td { border-bottom: none; }

.portfolio-row {
  position: relative;
  transition: background 0.15s;
}

.portfolio-row:focus-within {
  z-index: 30;
}

.portfolio-row:hover td {
  background: rgba(255, 255, 255, 0.024);
}

/* Row profit/loss tint — subtle left border indicator */
.portfolio-row.row-profit td:first-child {
  box-shadow: inset 3px 0 0 rgba(62, 255, 168, 0.5);
}

.portfolio-row.row-loss td:first-child {
  box-shadow: inset 3px 0 0 rgba(255, 85, 85, 0.45);
}

.portfolio-row.row-pinned {
  background: rgba(90, 171, 255, 0.04);
}

.portfolio-row.row-pinned td:first-child {
  box-shadow: inset 3px 0 0 rgba(90, 171, 255, 0.6);
}

/* Column widths */
/* Column widths — proportional % for no horizontal scroll */
th:nth-child(1), td:nth-child(1) { width: 7%; }
th:nth-child(2), td:nth-child(2) { width: 15%; }
th:nth-child(3), td:nth-child(3) { width: 16%; }
th:nth-child(4), td:nth-child(4) { width: 12.5%; }
th:nth-child(5), td:nth-child(5) { width: 12.5%; }
th:nth-child(6), td:nth-child(6) { width: 15%; }
th:nth-child(7), td:nth-child(7) { width: 10%; }
th:nth-child(8), td:nth-child(8) { width: 12%; }

/* ── Table inputs ── */

.table-input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}

.table-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(62, 255, 168, 0.06);
  box-shadow: 0 0 0 2px rgba(62, 255, 168, 0.08);
}

.table-input::placeholder {
  color: var(--muted-2);
  font-weight: 400;
}

:root[data-theme="light"] .table-input {
  background: rgba(0, 0, 0, 0.04);
}

.asset-input {
  font-family: var(--font-body);
  font-weight: 600;
}

/* ── Cell layouts ── */

.flag-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: center;
  text-decoration: none;
}

.flag-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.flag-btn:hover { border-color: var(--line-strong); }
.flag-btn.web-btn.is-active { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.08); }
.flag-btn.web-btn.is-active:hover { background: rgba(59,130,246,0.16); }
.flag-btn.web-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.flag-btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.asset-cell {
  position: relative;
  overflow: visible;
}

.asset-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  overflow: visible;
}

.asset-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
}

.asset-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.field-stack {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  text-align: center;
  overflow: visible;
}

.asset-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.lookup-meta,
.validation-meta {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 4px;
}

.lookup-meta.good     { color: var(--positive); background: var(--positive-bg); }
.lookup-meta.warn     { color: var(--warning); background: var(--warning-bg); }
.lookup-meta.error    { color: var(--negative); background: var(--negative-bg); }
.validation-meta.info { color: var(--neutral); }
.validation-meta.error { color: var(--negative); }

.compact-grid,
.tp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  justify-items: center;
}

.mini-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  min-width: 0;
}

.mini-field span {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}

.market-metrics {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.market-metrics strong {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.performance-metrics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* Money & numeric */
.money,
.numeric {
  font-family: var(--font-mono);
  font-weight: 700;
}

.numeric { font-size: 0.82rem; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--neutral); }
.warning  { color: var(--warning); }

/* Price cells */
.price-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.price-subline {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted-2);
}

.price-badge,
.signal-badge,
.delta-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  max-width: 100%;
  text-align: center;
}

.price-badge.good,
.signal-badge.good,
.delta-chip.good {
  color: var(--positive);
  background: var(--positive-bg);
  border-color: rgba(62, 255, 168, 0.22);
}

.price-badge.warn,
.signal-badge.warn,
.delta-chip.warn {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(255, 201, 71, 0.24);
}

.price-badge.error,
.signal-badge.error,
.delta-chip.error {
  color: var(--negative);
  background: var(--negative-bg);
  border-color: rgba(255, 85, 85, 0.22);
}

.signal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: signalPulse 2s ease-in-out infinite;
}

.signal-badge.good .signal-dot {
  animation: signalPulse 2s ease-in-out infinite;
}

.signal-badge.warn .signal-dot,
.signal-badge.error .signal-dot {
  animation: none;
}

/* Actions */
.action-stack {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.icon-btn {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  width: 100%;
  min-width: 0;
  text-align: center;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
  transform: none;
}

/* Suggestions */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 200;
  min-width: max(240px, 100%);
  max-width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.suggestion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
  font-size: 0.82rem;
}

.suggestion-btn:hover {
  background: var(--panel-hover);
}

.suggestion-btn img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.suggestion-btn > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.suggestion-btn strong {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-symbol {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.suggestion-rank {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted-2);
  white-space: nowrap;
}

/* ── Totals row ── */

.totals-row td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding: 10px 10px 10px 12px;
  background:
    linear-gradient(90deg, rgba(62, 255, 168, 0.08), rgba(90, 171, 255, 0.06)),
    rgba(5, 12, 22, 0.99);
  border-top: 1px solid rgba(62, 255, 168, 0.22);
  border-bottom: none;
  font-weight: 700;
  vertical-align: middle;
}

.totals-row td:first-child { border-bottom-left-radius: 16px; }
.totals-row td:last-child  { border-bottom-right-radius: 16px; }

:root[data-theme="light"] .totals-row td {
  background:
    linear-gradient(90deg, rgba(0, 137, 94, 0.08), rgba(26, 110, 199, 0.05)),
    rgba(255, 255, 255, 0.99);
  border-top-color: rgba(0, 137, 94, 0.2);
}

.totals-label-cell {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--accent);
}

.totals-inline-cell {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.totals-inline-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.totals-tp-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.totals-tp-chip {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
}

.totals-tp-chip strong {
  color: var(--muted);
  margin-right: 4px;
}

/* ── Insights ── */

.insights-panel .panel-heading { margin-bottom: 20px; }

.insights-rankings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.insight-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 18px;
  overflow: hidden;
}

.insight-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.insight-card-head h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-2);
}

.insight-card-head p {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.insight-chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.insight-chip.positive { color: var(--positive); border-color: rgba(62,255,168,0.2); background: var(--positive-bg); }
.insight-chip.negative { color: var(--negative); border-color: rgba(255,85,85,0.2); background: var(--negative-bg); }
.insight-chip.neutral  { color: var(--neutral); }

.insight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.insight-item:hover { border-color: var(--line); }

.insight-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.insight-item-rank {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.insight-item-main > div {
  min-width: 0;
  overflow: hidden;
}

.insight-item-main strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-item-main small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.insight-item-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.insight-item-metric strong {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.insight-item-metric small {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.insight-empty {
  padding: 14px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Info panel ── */

.info-grid {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.info-grid article {
  flex: 1;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.info-grid article h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-2);
}

/* ── Activity ── */

.activity-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.activity-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  transition: border-color 0.15s;
}

.activity-item:hover { border-color: var(--line-strong); }

.activity-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  font-weight: 600;
}

.activity-item strong.positive { color: var(--positive); }
.activity-item strong.negative { color: var(--negative); }
.activity-item strong.warning  { color: var(--warning); }

.activity-item p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.82rem;
}

.activity-item time {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted-2);
}

/* ── Footer ── */

.app-footer {
  background: none;
  border-color: var(--line);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.footer-copy h2 {
  margin-top: 8px;
  font-size: 1.1rem;
}

.footer-copy p {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer-wallets {
  display: grid;
  gap: 10px;
}

.wallet-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-soft);
  transition: border-color 0.15s;
}

.wallet-card:hover { border-color: var(--line-accent); }

.wallet-card span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.wallet-card code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  word-break: break-all;
  color: var(--text-2);
}

/* ── Loader ── */

.app-loader {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 99px;
  border: 1px solid rgba(90, 171, 255, 0.28);
  background: rgba(5, 13, 24, 0.94);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(90, 171, 255, 0.1) inset;
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

:root[data-theme="light"] .app-loader {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(26, 110, 199, 0.22);
}

.app-loader.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.loader-ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-2);
  animation: spin 0.7s linear infinite;
}

/* ── Toasts ── */

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(100% - 28px, 340px);
}

.toast {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(5, 13, 24, 0.97);
  box-shadow: var(--shadow);
  color: var(--text);
  animation: slideUp 0.2s ease;
  backdrop-filter: blur(16px);
}

:root[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.98);
}

.toast.positive { border-color: rgba(62, 255, 168, 0.3); }
.toast.negative { border-color: rgba(255, 85, 85, 0.3); }
.toast.warning  { border-color: rgba(255, 201, 71, 0.32); }

.toast strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.toast p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ── Misc ── */

.empty-cell { color: var(--muted-2); font-size: 0.78rem; }

.empty-state {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
}

.hidden { display: none !important; }

/* ── Animations ── */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes signalPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px currentColor; }
  50%       { opacity: 0.5; box-shadow: 0 0 10px currentColor; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.86); }
  50%       { opacity: 1; transform: scale(1); }
}

/* Entry animation for rows */
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.portfolio-row {
  animation: rowIn 0.22s ease forwards;
}

.loader-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 0.9s ease-in-out infinite;
}

/* ── Responsive ── */

@media (max-width: 1400px) {
  .insights-rankings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .hero-panel,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insights-rankings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .info-grid {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 12px);
    padding: 8px 6px 20px;
    gap: 8px;
  }

  .hero-panel, .panel {
    padding: 18px;
    border-radius: var(--radius-lg);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .insights-rankings-grid {
    grid-template-columns: 1fr;
  }

  .toolbar, .toolbar-group, .top-actions, .status-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-head, .chart-head-tools, .chart-range-control {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-range-control { flex-direction: row; flex-wrap: wrap; }

  .activity-list { grid-template-columns: 1fr; }

  .toast-stack {
    left: 10px;
    right: 10px;
    width: auto;
  }

  .app-loader {
    left: 10px;
    right: 10px;
    width: auto;
    justify-content: center;
  }

  .table-wrap { overflow: visible; }
  table { table-layout: auto; }

  .compact-grid, .tp-grid, .action-stack {
    grid-template-columns: 1fr;
  }
}

/* ── Side-heading variant ── */
.side-heading {
  flex-direction: row;
}

/* ── Light mode overrides ── */

:root[data-theme="light"] .totals-row td {
  background:
    linear-gradient(90deg, rgba(0, 137, 94, 0.08), rgba(26, 110, 199, 0.05)),
    rgba(255, 255, 255, 0.99);
}

:root[data-theme="light"] body::after {
  display: none;
}

:root[data-theme="light"] body::before {
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
}

/* ── Light mode: sticky bar ── */
:root[data-theme="light"] .sticky-bar {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 137, 94, 0.2);
  box-shadow: 0 4px 18px rgba(14, 40, 70, 0.1), 0 1px 0 rgba(0, 137, 94, 0.08) inset;
}

/* ── Light mode: footer ── */
:root[data-theme="light"] .app-footer {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(30, 70, 110, 0.12);
}

:root[data-theme="light"] .footer-copy h2 {
  color: var(--text);
}

:root[data-theme="light"] .footer-copy p {
  color: var(--text-2);
}

:root[data-theme="light"] .wallet-card {
  background: rgba(240, 244, 248, 0.9);
  border-color: rgba(30, 70, 110, 0.15);
}

:root[data-theme="light"] .wallet-card code {
  color: var(--text);
}

:root[data-theme="light"] .wallet-card span {
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════
   ENHANCEMENTS v3 — Column toggles, mobile cards,
   hero redesign, design system, toasts, animations
   ═══════════════════════════════════════════════════════ */

/* ── Column toggle buttons ── */

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.column-toggles-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--muted);
  margin-right: 4px;
}

.col-toggle-btn {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.col-toggle-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.col-toggle-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Table overflow fix ── */

.table-wrap {
  overflow: visible;
  -webkit-overflow-scrolling: auto;
}

/* ── Glass surface variable ── */

:root {
  --surface-glass: rgba(8, 16, 26, 0.75);
  --shadow-sm: 0 4px 12px rgba(1, 6, 14, 0.2);
  --shadow-md: 0 12px 36px rgba(1, 6, 14, 0.35);
  --shadow-lg: 0 32px 80px rgba(1, 6, 14, 0.5);
}

:root[data-theme="light"] {
  --surface-glass: rgba(255, 255, 255, 0.75);
  --shadow-sm: 0 2px 8px rgba(14, 40, 70, 0.06);
  --shadow-md: 0 8px 28px rgba(14, 40, 70, 0.1);
  --shadow-lg: 0 20px 60px rgba(14, 40, 70, 0.14);
}

/* ── Smooth theme transition ── */

:root {
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.hero-panel, .panel, .summary-card, .chart-card, .toast, .sticky-bar {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ── Hero redesign — compact horizontal layout ── */

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "copy controls";
  gap: 20px;
  padding: 22px 28px;
}

.hero-copy {
  grid-area: copy;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
}

.hero-copy .eyebrow { flex-basis: 100%; }

.hero-copy h1 {
  margin-top: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.portfolio-name-display {
  margin-top: 0;
}

.hero-side {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Versión compacta de las tarjetas de estado dentro del hero rediseñado */
.status-strip .status-card {
  padding: 10px 14px;
  min-width: 150px;
}

.status-strip .status-card strong {
  margin-top: 4px;
  font-size: 0.8rem;
}

.status-strip .status-card small {
  margin-top: 3px;
  font-size: 0.72rem;
}

/* ── Status badges in nav (sticky bar) ── */

.nav-status-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 8px;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-soft);
}

.nav-badge .nav-badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.nav-badge.good .nav-badge-dot { background: var(--positive); }
.nav-badge.warn .nav-badge-dot { background: var(--warning); }
.nav-badge.error .nav-badge-dot { background: var(--negative); }

/* ── Enhanced toasts ── */

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
  animation: toastSlideIn 0.3s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  animation: toastProgress 4.2s linear forwards;
}

.toast.positive .toast-progress { background: var(--positive); }
.toast.negative .toast-progress { background: var(--negative); }
.toast.warning .toast-progress { background: var(--warning); }
.toast.neutral .toast-progress { background: var(--accent-2); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ── TP pulse animation ── */

.signal-badge.warn .signal-dot {
  animation: tpPulse 1.5s ease-in-out infinite;
}

@keyframes tpPulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 4px currentColor; }
  50% { opacity: 0.6; transform: scale(1.3); box-shadow: 0 0 12px currentColor; }
}

/* ── Mobile card layout ── */

@media (max-width: 768px) {
  /* En móvil la tabla de escritorio se sustituye por la lista de tarjetas
     (ver sección "MÓVIL — tarjetas de activo y mercado" al final del archivo). */
  .column-toggles {
    flex-wrap: wrap;
  }

  .compact-grid, .tp-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    grid-template-areas: "copy" "controls";
  }
}

/* ── Accesibilidad ── */

button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

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

/* ═══════════════════════════════════════════════════════
   MOBILE-FIRST v4 — Sin overflow horizontal, targets
   táctiles 44px, menú "Más", acordeón de posiciones,
   sticky bar móvil, safe areas (notch / barra inferior)
   ═══════════════════════════════════════════════════════ */

/* ── Guardas globales contra overflow horizontal ── */

html {
  overflow-x: hidden;
}

img, video {
  max-width: 100%;
  height: auto;
}

canvas, svg {
  max-width: 100%;
}

.panel,
.hero-panel,
.hero-copy,
.hero-side,
.toolbar,
.toolbar-group,
.chart-card,
.chart-stage,
.summary-card,
.insight-card,
.activity-item,
.table-wrap {
  min-width: 0;
  max-width: 100%;
}

/* Tipografía fluida base */
body {
  font-size: clamp(14px, 0.5vw + 13.2px, 15px);
}

/* Safe areas (notch lateral y barra inferior del navegador) */
.app-shell {
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.toast-stack {
  bottom: calc(14px + env(safe-area-inset-bottom));
  right: max(14px, env(safe-area-inset-right));
}

/* ── Menú "Más opciones" (solo móvil; en escritorio todo visible) ── */

.more-actions-btn {
  display: none;
}

/* ── Toggle "Ver detalles" de tarjetas (solo móvil) ── */

.card-toggle-cell {
  display: none;
  padding: 0;
  border: none;
}

.details-toggle-btn {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: var(--panel-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.details-toggle-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ── Layout móvil ── */

@media (max-width: 768px) {

  /* App shell compacto con safe areas */
  .app-shell {
    width: 100%;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
             calc(24px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 10px;
  }

  /* Targets táctiles: mínimo 44px y fuente 16px en campos
     (evita el zoom automático de iOS al enfocar inputs) */
  .primary-btn,
  .ghost-btn,
  .danger-btn,
  .icon-btn,
  .flag-btn,
  .suggestion-btn,
  select {
    min-height: 44px;
  }

  .inline-input,
  .table-input {
    min-height: 44px;
    font-size: 16px;
  }

  select,
  .inline-input {
    font-size: 16px;
  }

  .range-chip {
    min-height: 36px;
    padding: 0 12px;
  }

  .col-toggle-btn {
    min-height: 38px;
  }

  .action-stack,
  .flag-stack {
    gap: 8px;
  }

  /* Encabezado: campos en filas compactas de 2 columnas */
  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .inline-field-wide,
  #themeToggle {
    grid-column: 1 / -1;
  }

  .inline-field {
    min-width: 0;
    padding: 10px 12px;
  }

  .status-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .status-card {
    min-width: 0;
    padding: 10px 12px;
  }

  /* Barra de acciones: primarias visibles, secundarias en "Más" */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar-primary {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .more-actions-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .more-actions-btn[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
  }

  .toolbar-secondary {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }

  .toolbar.is-open .toolbar-secondary {
    display: flex;
  }

  /* Sticky bar compacta en móvil (no tapa contenido: aparece
     solo cuando el hero sale de pantalla). Datos centrados: valor + PnL. */
  .sticky-bar {
    display: flex;
    justify-content: center;
    top: max(8px, env(safe-area-inset-top));
    width: calc(100% - 16px);
    padding: 6px 10px;
    gap: 8px;
  }

  /* En la barra compacta el nombre es redundante (ya está en la cabecera
     principal). Se oculta para que el valor total sea el elemento dominante. */
  .sticky-bar-title {
    display: none;
  }

  /* Sin insignias de estado ("Conectado a CoinGecko", guardado) en la
     barra de scroll: el estado ya vive en la cabecera y en Ajustes. */
  .sticky-bar-right {
    display: none;
  }

  .sticky-bar-value {
    font-size: 0.92rem;
  }

  .sticky-bar-pnl {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .sticky-bar-sep {
    display: none;
  }

  #navSaveBadge {
    display: none;
  }

  /* Loader bajo la sticky bar para no solaparse */
  .app-loader {
    top: max(60px, calc(env(safe-area-inset-top) + 52px));
  }

  /* Gráficos: alto fluido y sin desbordes */
  .chart-stage {
    height: clamp(200px, 58vw, 260px);
  }

  /* La tabla de posiciones se oculta en móvil (ver .portfolio-mobile-list).
     Las reglas legacy de conversión tabla→tarjeta se retiraron. */
}

/* ── Pantallas muy estrechas (320–360px) ── */

@media (max-width: 360px) {
  .hero-panel,
  .panel {
    padding: 14px;
  }

  .top-actions,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .table-wrap .portfolio-row .compact-grid,
  .table-wrap .portfolio-row .tp-grid {
    grid-template-columns: 1fr 1fr;
  }

  .sticky-bar .nav-status-badges {
    display: none;
  }

  .hero-copy h1 {
    font-size: clamp(1.35rem, 7vw, 1.6rem);
  }
}

/* ═══════════════════════════════════════════════════════
   LIQUID GLASS v5 — estética de cristal líquido de iOS:
   materiales translúcidos con blur+saturación, brillo
   especular superior, cápsulas y esquinas continuas
   ═══════════════════════════════════════════════════════ */

:root {
  --glass-bg:        rgba(12, 22, 36, 0.52);
  --glass-bg-strong: rgba(9, 17, 29, 0.68);
  --glass-inner:     linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015) 45%, rgba(255, 255, 255, 0) 70%);
  --glass-card:      linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  --glass-border:    rgba(255, 255, 255, 0.10);
  --glass-highlight: rgba(255, 255, 255, 0.14);
  --glass-shadow:    0 12px 40px rgba(1, 6, 14, 0.45);
}

:root[data-theme="light"] {
  --glass-bg:        rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.75);
  --glass-inner:     linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 85%);
  --glass-card:      linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.55));
  --glass-border:    rgba(255, 255, 255, 0.8);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --glass-shadow:    0 12px 40px rgba(14, 40, 70, 0.14);
}

/* Fondo con manchas de color suaves: dan algo que "refractar" al cristal */
body {
  background-image:
    radial-gradient(ellipse 55% 40% at 10% 0%, rgba(90, 171, 255, 0.17), transparent 65%),
    radial-gradient(ellipse 45% 35% at 92% 6%, rgba(62, 255, 168, 0.13), transparent 60%),
    radial-gradient(ellipse 50% 40% at 78% 62%, rgba(143, 121, 255, 0.11), transparent 65%),
    radial-gradient(ellipse 60% 45% at 12% 92%, rgba(78, 160, 255, 0.10), transparent 65%);
  background-attachment: fixed;
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 55% 40% at 10% 0%, rgba(26, 110, 199, 0.15), transparent 65%),
    radial-gradient(ellipse 45% 35% at 92% 6%, rgba(0, 137, 94, 0.12), transparent 60%),
    radial-gradient(ellipse 50% 40% at 78% 62%, rgba(120, 90, 220, 0.10), transparent 65%);
  background-attachment: fixed;
}

/* El cristal de iOS es limpio: fuera scanlines */
body::after {
  display: none;
}

/* ── Paneles principales: cristal profundo ── */

.hero-panel,
.panel {
  background: var(--glass-inner), var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
  border-radius: 26px;
}

:root[data-theme="light"] .hero-panel,
:root[data-theme="light"] .panel,
:root[data-theme="light"] .app-footer {
  background: var(--glass-inner), var(--glass-bg);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}

/* ── Tarjetas interiores: cristal ligero (sin blur anidado, por rendimiento) ── */

.summary-card,
.chart-card,
.insight-card,
.activity-item,
.status-card,
.inline-field,
.wallet-card,
.info-grid article {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 20px;
}

:root[data-theme="light"] .summary-card,
:root[data-theme="light"] .chart-card,
:root[data-theme="light"] .insight-card,
:root[data-theme="light"] .activity-item,
:root[data-theme="light"] .status-card,
:root[data-theme="light"] .inline-field,
:root[data-theme="light"] .wallet-card,
:root[data-theme="light"] .info-grid article {
  background: var(--glass-card);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 10px rgba(14, 40, 70, 0.06);
}

.summary-card:hover {
  border-color: var(--glass-highlight);
}

/* ── Controles: cápsulas de cristal ── */

.primary-btn,
.ghost-btn,
.danger-btn,
.details-toggle-btn,
select {
  border-radius: 999px;
}

.icon-btn,
.flag-btn,
.col-toggle-btn,
.range-chip,
.th-sort-btn {
  border-radius: 999px;
}

.inline-input {
  border-radius: 14px;
}

.table-input {
  border-radius: 10px;
}

.ghost-btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ghost-btn:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05));
  border-color: rgba(255, 255, 255, 0.2);
}

:root[data-theme="light"] .ghost-btn {
  background: var(--glass-card);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 1px 4px rgba(14, 40, 70, 0.08);
  color: var(--text);
}

.primary-btn {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 20px rgba(62, 255, 168, 0.2);
}

.details-toggle-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

:root[data-theme="light"] .details-toggle-btn {
  border-color: var(--glass-border);
  background: var(--glass-card);
  color: var(--text-2);
}

/* ── Elementos flotantes: cristal fuerte ── */

.sticky-bar {
  background: var(--glass-inner), var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(36px) saturate(190%);
  -webkit-backdrop-filter: blur(36px) saturate(190%);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 8px 30px rgba(1, 6, 14, 0.4);
}

:root[data-theme="light"] .sticky-bar {
  background: var(--glass-inner), var(--glass-bg-strong);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 8px 30px rgba(14, 40, 70, 0.14);
}

.toast {
  background: var(--glass-inner), var(--glass-bg-strong);
  border-color: var(--glass-border);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}

:root[data-theme="light"] .toast {
  background: var(--glass-inner), var(--glass-bg-strong);
}

.app-loader {
  background: var(--glass-inner), var(--glass-bg-strong);
  border-color: var(--glass-border);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-sm);
}

:root[data-theme="light"] .app-loader {
  background: var(--glass-inner), var(--glass-bg-strong);
  border-color: var(--glass-border);
}

.suggestions {
  background: var(--glass-inner), var(--glass-bg-strong);
  border-color: var(--glass-border);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}

/* ── Tarjetas de posición y totales en móvil: cristal ── */

@media (max-width: 768px) {
  .table-wrap .portfolio-row,
  .table-wrap .totals-row {
    background: var(--glass-card);
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 6px 24px rgba(1, 6, 14, 0.22);
  }

  :root[data-theme="light"] .table-wrap .portfolio-row,
  :root[data-theme="light"] .table-wrap .totals-row {
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 4px 16px rgba(14, 40, 70, 0.08);
  }

  .table-wrap .totals-row {
    border-color: var(--line-accent);
  }
}

/* ── Copiar billeteras con un toque ── */

.wallet-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wallet-copy-btn {
  min-height: 36px;
  padding: 0 16px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.wallet-copy-btn.is-copied {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* La propia dirección también copia al tocarla/clicarla */
.wallet-card code[data-copy-wallet] {
  cursor: pointer;
  transition: color 0.15s;
}

.wallet-card code[data-copy-wallet]:hover {
  color: var(--accent);
}

.wallet-card code.is-copied {
  color: var(--accent);
}

@media (max-width: 768px) {
  .wallet-copy-btn {
    min-height: 44px;
  }
}

/* ═══════════════════════════════════════════════════════
   LIQUID GLASS v6 — pulido visual (oscuro y claro) y fix
   del buscador de activos (z-order entre paneles)
   ═══════════════════════════════════════════════════════ */

/* ── Fix buscador: los paneles con backdrop-filter crean contexto de
   apilamiento, y el historial (posterior en el DOM) tapaba el desplegable
   de sugerencias. El panel de la tabla se eleva sobre sus hermanos,
   y aún más mientras se está editando dentro. ── */

.panel,
.hero-panel {
  position: relative;
}

.table-panel {
  z-index: 6;
}

.table-panel:focus-within {
  z-index: 45;
}

/* El desplegable no crece sin límite: alto máximo con scroll propio */
.suggestions {
  max-height: min(320px, 48vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.suggestion-btn + .suggestion-btn {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

:root[data-theme="light"] .suggestion-btn + .suggestion-btn {
  border-top: 1px solid rgba(30, 70, 110, 0.08);
}

/* ── Feedback táctil tipo iOS al pulsar ── */

.primary-btn:active,
.ghost-btn:active,
.danger-btn:active,
.icon-btn:active,
.flag-btn:active,
.range-chip:active,
.col-toggle-btn:active,
.details-toggle-btn:active,
.suggestion-btn:active {
  transform: scale(0.96);
}

/* ── Cabecera de tabla: cristal translúcido (se ve el contenido pasar
   por debajo al hacer scroll con el thead fijo) ── */

th {
  background: rgba(10, 18, 30, 0.72);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

:root[data-theme="light"] th {
  background: rgba(255, 255, 255, 0.72);
}

/* ── Inputs: cristal hundido con foco luminoso ── */

.table-input {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

.table-input:focus {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 3px rgba(62, 255, 168, 0.14);
}

:root[data-theme="light"] .table-input {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(30, 70, 110, 0.12);
  box-shadow: inset 0 1px 2px rgba(14, 40, 70, 0.08);
}

:root[data-theme="light"] .table-input:focus {
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(14, 40, 70, 0.05), 0 0 0 3px rgba(0, 137, 94, 0.14);
}

.inline-input {
  background: rgba(5, 12, 22, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] .inline-input {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 1px 2px rgba(14, 40, 70, 0.07);
}

/* ── Selects como cápsulas de cristal ── */

select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236d8fa8'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

:root[data-theme="light"] select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a7a92'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 4px rgba(14, 40, 70, 0.08);
}

/* ── Chips activos con brillo de cristal ── */

.range-chip.is-active,
.col-toggle-btn.is-active,
.flag-btn.is-active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 12px rgba(62, 255, 168, 0.12);
}

:root[data-theme="light"] .range-chip.is-active,
:root[data-theme="light"] .col-toggle-btn.is-active,
:root[data-theme="light"] .flag-btn.is-active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 0 10px rgba(0, 137, 94, 0.12);
}

/* ── Estado vacío y tarjetas sueltas ── */

.empty-state {
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  border-radius: 18px;
}

/* ── Barras de desplazamiento finas y translúcidas ── */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 150, 180, 0.35) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(120, 150, 180, 0.3);
  border-radius: 99px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Fondo claro más rico (una mancha cálida extra) ── */

:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 55% 40% at 10% 0%, rgba(26, 110, 199, 0.16), transparent 65%),
    radial-gradient(ellipse 45% 35% at 92% 6%, rgba(0, 137, 94, 0.13), transparent 60%),
    radial-gradient(ellipse 50% 40% at 78% 62%, rgba(120, 90, 220, 0.11), transparent 65%),
    radial-gradient(ellipse 45% 35% at 12% 90%, rgba(240, 150, 40, 0.08), transparent 65%);
}

/* ═══════════════════════════════════════════════════════
   MOBILE UX v7 — gráfico de evolución primero y táctil,
   tarjetas compactas con resumen 2 columnas, barra de
   acciones reubicada y barra rápida inferior fija
   ═══════════════════════════════════════════════════════ */

/* ── Cabecera del gráfico de evolución (valor + variación del rango) ── */

.chart-head-copy {
  min-width: 0;
}

.chart-current {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-current strong {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Estado vacío elegante del gráfico */
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--glass-card);
  border-radius: 14px;
}

/* ── Filtro de posiciones ── */

.table-filter {
  margin-bottom: 12px;
}

.table-filter .inline-input {
  max-width: 340px;
}

/* ── Números tabulares para columnas alineadas ── */

.money,
.numeric,
.card-summary-grid strong,
.totals-inline-cell {
  font-variant-numeric: tabular-nums;
}

/* ── Resumen de tarjeta (solo móvil; en escritorio no existe) ── */

.card-summary-cell {
  display: none;
  padding: 0;
  border: none;
}

/* ── Orden en móvil (el thead está oculto en tarjetas) ── */

.mobile-sort {
  display: none;
}

/* ── Layout móvil v7 ── */

@media (max-width: 768px) {

  /* Gráficos en móvil: solo la dona de distribución; el gráfico lineal
     de evolución queda reservado para tablet/escritorio */
  .chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-grid .chart-card:nth-child(2) {
    display: none;
  }

  .chart-grid .chart-card:first-child .chart-stage {
    height: clamp(220px, 64vw, 260px);
  }

  /* Chips de rango: envuelven en varias filas (sin scroll lateral) */
  .chart-range-control {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 100%;
    padding-bottom: 2px;
  }

  .range-chip {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
    padding: 0 14px;
  }

  /* Barra de acciones: rejilla de 2 columnas, táctil y sin overflow */
  .toolbar-primary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .toolbar.is-open .toolbar-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .toolbar-secondary .danger-btn {
    grid-column: 1 / -1;
  }

  /* ── Tarjeta de posición v7 ──
     Cabecera: activo + favorito/web. Resumen 2 columnas siempre visible.
     Acordeón: edición (inv/tokens/entrada), TP escalera, señal y acciones. */

  .table-wrap .portfolio-row .asset-cell {
    order: 1;
    flex: 1 1 0%;
    min-width: 0;
  }

  .table-wrap .portfolio-row .priority-cell {
    order: 2;
    flex: 0 0 auto;
    display: block;
    padding-top: 0;
  }

  .table-wrap .portfolio-row:not(.is-expanded) .priority-cell {
    display: block;
  }

  .table-wrap .portfolio-row .priority-cell::before {
    display: none;
    content: none;
  }

  .table-wrap .portfolio-row .priority-cell .flag-stack {
    display: flex;
    flex-direction: row;
    gap: 6px;
  }

  .table-wrap .portfolio-row .priority-cell .flag-btn {
    width: auto;
    min-height: 40px;
    padding: 0 10px;
    white-space: nowrap;
  }

  /* Los datos de mercado/rendimiento viven en el resumen: las celdas
     originales se ocultan en móvil (siguen actualizándose por data-role) */
  .table-wrap .portfolio-row .market-cell,
  .table-wrap .portfolio-row .performance-cell {
    display: none;
  }

  .card-summary-cell {
    display: block;
    order: 3;
    flex: 1 1 100%;
  }

  .card-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }

  :root[data-theme="light"] .card-summary-grid {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(30, 70, 110, 0.08);
  }

  .cs-item {
    min-width: 0;
  }

  .cs-item span {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 2px;
  }

  .cs-item strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cs-right {
    text-align: right;
  }

  .cs-tp {
    grid-column: 1 / -1;
  }

  .card-summary-grid strong.good  { color: var(--positive); }
  .card-summary-grid strong.warn  { color: var(--warning); }
  .card-summary-grid strong.error { color: var(--negative); }

  .card-summary-cell::before {
    display: none;
    content: none;
  }

  /* Toggle debajo del resumen, ancho completo con flecha indicadora */
  .table-wrap .portfolio-row .card-toggle-cell {
    order: 4;
    flex: 1 1 100%;
    margin-left: 0;
  }

  .table-wrap .portfolio-row .details-toggle-btn {
    width: 100%;
  }

  .details-toggle-btn::after {
    content: "\25BE";
    margin-left: 8px;
    display: inline-block;
    transition: transform 0.2s;
  }

  .portfolio-row.is-expanded .details-toggle-btn::after {
    transform: rotate(180deg);
  }

  /* Acordeón */
  .table-wrap .portfolio-row .position-cell { order: 5; }
  .table-wrap .portfolio-row .targets-cell  { order: 6; }
  .table-wrap .portfolio-row .signal-cell   { order: 7; flex: 1 1 100%; }
  .table-wrap .portfolio-row .actions-cell  { order: 8; }

  .table-wrap .portfolio-row:not(.is-expanded) .signal-cell {
    display: none;
  }

  /* Borde lateral según beneficio/pérdida (sistema visual actual) */
  .table-wrap .portfolio-row.row-profit {
    border-left: 3px solid rgba(62, 255, 168, 0.55);
  }

  .table-wrap .portfolio-row.row-loss {
    border-left: 3px solid rgba(255, 85, 85, 0.5);
  }

  /* Objetivos TP como escalera: TP1 → TP2 → TP3 en filas */
  .table-wrap .portfolio-row .tp-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .table-wrap .portfolio-row .tp-grid .mini-field {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .table-wrap .portfolio-row .tp-grid .mini-field span {
    flex-shrink: 0;
  }

  .table-wrap .portfolio-row .tp-grid .mini-field input {
    max-width: 58%;
  }

  /* Filtro a todo el ancho en móvil */
  .table-filter .inline-input {
    max-width: 100%;
  }

  /* Control de orden móvil: selector de columna + botón de dirección */
  .mobile-sort {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
  }

  .mobile-sort-field {
    flex: 1;
    min-width: 0;
  }

  .mobile-sort-field span {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
  }

  .mobile-sort-dir {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 44px;
    font-size: 1.05rem;
    font-weight: 700;
  }
}

/* ═══════════════════════════════════════════════════════
   APP v8 — cuatro pestañas (Inicio/Cartera/Analítica/Más),
   barra de navegación estilo iOS, pantalla de inicio con
   widgets de mercado y bottom sheets para posiciones
   ═══════════════════════════════════════════════════════ */

/* ── Pestañas: solo la activa es visible ── */

.tab-section {
  display: none;
  animation: tabIn 0.22s ease;
}

body[data-active-tab="home"] .tab-section[data-tab="home"],
body[data-active-tab="markets"] .tab-section[data-tab="markets"],
body[data-active-tab="plan"] .tab-section[data-tab="plan"],
body[data-active-tab="analytics"] .tab-section[data-tab="analytics"],
body[data-active-tab="more"] .tab-section[data-tab="more"] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@keyframes tabIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Barra de navegación ── */

.tab-bar {
  position: fixed;
  z-index: 70;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(32px) saturate(185%);
  -webkit-backdrop-filter: blur(32px) saturate(185%);
  border: 1px solid var(--glass-border);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 14px;
  transition: color 0.15s, background 0.15s, transform 0.12s;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
}

.tab-btn:active {
  transform: scale(0.94);
}

.tab-btn.is-active {
  color: var(--accent);
}

/* Móvil: barra inferior fija con safe area */
@media (max-width: 768px) {
  .tab-bar {
    left: 0;
    right: 0;
    bottom: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    padding: 6px 10px max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 28px rgba(1, 6, 14, 0.35);
  }

  :root[data-theme="light"] .tab-bar {
    box-shadow: 0 -8px 28px rgba(14, 40, 70, 0.12);
  }

  .app-shell {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .toast-stack {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* Escritorio/tablet: barra superior discreta */
@media (min-width: 769px) {
  .tab-bar {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 32px));
    border-radius: 999px;
    padding: 6px 8px;
    box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-sm);
  }

  .tab-btn {
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    font-size: 0.78rem;
  }

  .tab-btn svg {
    width: 18px;
    height: 18px;
  }

  .tab-btn.is-active {
    background: var(--accent-dim);
  }

  .app-shell {
    padding-top: calc(72px + env(safe-area-inset-top));
  }

  /* La sticky bar de scroll cede el sitio a la barra de pestañas */
  .sticky-bar {
    top: 74px;
  }
}

/* ── Pantalla Inicio ── */

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 0;
}

.home-header-main {
  min-width: 0;
}

.home-header .portfolio-name-display {
  margin-top: 0;
  font-size: 1.05rem;
}

.home-status {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-circle-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  color: var(--text-2);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: color 0.15s, transform 0.12s;
}

.icon-circle-btn:active {
  transform: scale(0.92);
}

.icon-circle-btn svg {
  width: 21px;
  height: 21px;
}

.icon-circle-btn .eye-closed { display: none; }
.icon-circle-btn.is-hidden-balance .eye-open { display: none; }
.icon-circle-btn.is-hidden-balance .eye-closed { display: block; }

/* Tarjeta principal de valor */
.main-value-card {
  position: relative;
  overflow: hidden;
  padding: 22px 22px 18px;
  border-radius: 24px;
  border: 1px solid var(--line-accent);
  background:
    radial-gradient(ellipse 90% 100% at 0% 0%, rgba(62, 255, 168, 0.09), transparent 60%),
    radial-gradient(ellipse 80% 90% at 100% 100%, rgba(90, 171, 255, 0.09), transparent 60%),
    var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mvc-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--muted);
}

.mvc-value {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.mvc-pnl {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.mvc-sparkline {
  width: 100%;
  height: 34px;
  margin-top: 4px;
}

.mvc-sparkline polyline {
  stroke: var(--accent);
  opacity: 0.75;
}

.mvc-meta {
  font-size: 0.7rem;
  color: var(--muted-2);
}

/* Tarjetas resumen mini (2x2 en móvil, fila en escritorio) */
.summary-card.mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
}

.summary-card.mini .summary-icon {
  color: var(--accent-2);
}

.summary-card.mini .summary-icon svg {
  width: 20px;
  height: 20px;
}

.summary-card.mini strong {
  margin-top: 2px;
  font-size: clamp(0.92rem, 3.6vw, 1.15rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-card.mini p {
  margin-top: 0;
  font-size: 0.68rem;
}

.summary-card.mini.positive strong { color: var(--positive); text-shadow: 0 0 14px rgba(62, 255, 168, 0.25); }
.summary-card.mini.negative strong { color: var(--negative); text-shadow: 0 0 14px rgba(255, 107, 107, 0.2); }

@media (max-width: 768px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

/* Sección Mercado */
.home-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin: 4px 4px 8px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 769px) {
  .market-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.market-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  min-height: 96px;
}

.market-card header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}

.market-card header img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.market-card strong {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-change {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.market-change small {
  color: var(--muted-2);
  font-weight: 400;
}

.market-meta {
  font-size: 0.6rem;
  color: var(--muted-2);
  line-height: 1.4;
}

.dominance-ring {
  width: 64px;
  height: 64px;
  align-self: center;
}

.dominance-ring .ring-text {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  fill: var(--text);
}

.fng-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.fng-value strong {
  font-size: 1.35rem;
}

.fng-value span {
  font-size: 0.72rem;
  color: var(--text-2);
  font-weight: 600;
}

.fng-bar {
  position: relative;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(90deg, #ff6b6b, #ffc947 50%, #3effa8);
  opacity: 0.85;
}

.fng-dot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Skeletons */
.market-skeleton {
  justify-content: center;
  gap: 8px;
}

.skeleton-line,
.chart-skeleton {
  border-radius: 8px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.05) 35%, rgba(255, 255, 255, 0.12) 50%, rgba(255, 255, 255, 0.05) 65%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-line { height: 12px; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w70 { width: 70%; }

.chart-skeleton {
  position: absolute;
  inset: 8px;
  border-radius: 14px;
  z-index: 1;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to   { background-position: -100% 0; }
}

/* Destacados de Inicio */
.hl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
}

.hl-item .asset-avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--muted);
}

.hl-item .asset-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hl-main {
  flex: 1;
  min-width: 0;
}

.hl-main strong {
  display: block;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hl-main small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hl-pct {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.hl-time {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted-2);
  flex-shrink: 0;
}

.hl-block + .hl-block {
  margin-top: 6px;
}

/* ── Pestaña Más ── */

.install-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.install-card-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--accent-dim);
  color: var(--accent);
}

.install-card-icon svg {
  width: 22px;
  height: 22px;
}

.install-card strong {
  display: block;
  font-size: 0.9rem;
}

.install-card p {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--muted);
}

.autorefresh-meta {
  margin: 10px 4px 12px;
  font-size: 0.74rem;
  color: var(--muted);
}

.more-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

@media (max-width: 768px) {
  .more-actions-grid {
    grid-template-columns: 1fr 1fr;
  }

  .more-actions-grid .danger-btn {
    grid-column: 1 / -1;
  }
}

/* El selector de orden también en escritorio (capitalización, ranking,
   variación 24h y próximo TP no tienen columna propia en la tabla) */
@media (min-width: 769px) {
  .mobile-sort {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 420px;
    margin-bottom: 12px;
  }

  .mobile-sort-field {
    flex: 1;
    min-width: 0;
  }

  .mobile-sort-field span {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
  }

  .mobile-sort-dir {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 42px;
    font-size: 1.05rem;
    font-weight: 700;
  }
}

/* Rank badge y línea de capitalización */
.rank-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: var(--panel-soft);
}

.cap-subline {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* Barra fina de progreso hacia el siguiente TP */
.tp-progress {
  display: block;
  margin-top: 5px;
  height: 4px;
  border-radius: 99px;
  background: rgba(120, 150, 180, 0.18);
  overflow: hidden;
}

.tp-progress span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.4s ease;
}

/* ── Bottom sheet de posiciones (móvil) ── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgba(2, 8, 16, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 768px) {
  body.sheet-open {
    overflow: hidden;
  }

  .table-wrap .portfolio-row.is-expanded {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    margin: 0;
    max-height: 86dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--glass-inner), var(--glass-bg-strong);
    backdrop-filter: blur(36px) saturate(185%);
    -webkit-backdrop-filter: blur(36px) saturate(185%);
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 -16px 50px rgba(1, 6, 14, 0.5);
    animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* Asa superior del sheet, como en iOS */
  .table-wrap .portfolio-row.is-expanded::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: rgba(150, 175, 200, 0.4);
    margin: 0 auto 10px;
    flex: 1 1 100%;
  }

  @keyframes sheetUp {
    from { transform: translateY(30%); opacity: 0.6; }
    to   { transform: translateY(0); opacity: 1; }
  }
}

/* ═══════════════════════════════════════════════════════
   PREMIUM v9 — dock flotante, filtros rápidos, reparto de
   capital, resumen analítico y pulido de scroll/solapes
   ═══════════════════════════════════════════════════════ */

/* ── Dock inferior flotante (móvil) ── */

@media (max-width: 768px) {
  .tab-bar {
    left: 14px;
    right: 14px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    border: 1px solid var(--glass-border);
    border-radius: 26px;
    padding: 6px;
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 12px 36px rgba(1, 6, 14, 0.45);
  }

  :root[data-theme="light"] .tab-bar {
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 12px 36px rgba(14, 40, 70, 0.16);
  }

  .tab-btn {
    border-radius: 20px;
    min-height: 52px;
  }

  .tab-btn.is-active {
    background: var(--accent-dim);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .tab-btn.is-active svg {
    transform: translateY(-1px) scale(1.06);
  }

  .tab-btn svg {
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* El contenido nunca queda bajo el dock flotante */
  .app-shell {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .toast-stack {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }

  /* El sheet queda por encima del dock */
  .table-wrap .portfolio-row.is-expanded {
    z-index: 80;
  }

  /* Acciones de Cartera: principal destacada a todo el ancho */
  .toolbar-primary {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-primary .primary-btn {
    grid-column: 1 / -1;
  }
}

/* ── Filtros rápidos de Cartera ── */

.quick-filters {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 10px;
  padding-bottom: 2px;
}

.quick-filters::-webkit-scrollbar {
  display: none;
}

.qf-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.12s;
}

.qf-chip:active {
  transform: scale(0.95);
}

.qf-chip.is-active {
  color: var(--accent);
  border-color: rgba(62, 255, 168, 0.35);
  background: var(--accent-dim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

@media (max-width: 768px) {
  .qf-chip {
    min-height: 42px;
  }
}

/* ── Reparto del capital (Inicio) ── */

.alloc-card {
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alloc-title {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--muted);
}

.alloc-bar {
  display: flex;
  height: 10px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(120, 150, 180, 0.14);
}

.alloc-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
}

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.alloc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.alloc-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.alloc-chip strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* ── Cabecera Mercado con tendencia ── */

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 4px 8px;
}

.home-section-head .home-section-title {
  margin: 0;
}

.trend-chip {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
}

.trend-chip.positive { color: var(--positive); border-color: rgba(62, 255, 168, 0.3); }
.trend-chip.negative { color: var(--negative); border-color: rgba(255, 85, 85, 0.3); }
.trend-chip.neutral  { color: var(--neutral); }

/* ── Insignia de categoría en posiciones ── */

.cat-badge {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-soft);
}

.cat-badge.cat-btc    { color: #f6b34c; border-color: rgba(246, 179, 76, 0.35); }
.cat-badge.cat-eth    { color: #7da4ff; border-color: rgba(125, 164, 255, 0.35); }
.cat-badge.cat-stable { color: var(--neutral); }

/* ── Resumen analítico ── */

.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.as-item {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  min-width: 0;
}

.as-item span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.as-item strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

@media (max-width: 768px) {
  .analytics-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Más: fila de autorefresh con acción manual ── */

.autorefresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.autorefresh-row .autorefresh-meta {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

/* Las 6 tarjetas del resumen fluyen según el ancho disponible */
@media (min-width: 769px) {
  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

/* ── Estado vacío premium ── */

.empty-state {
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.empty-state::before {
  content: "◎";
  font-size: 1.8rem;
  color: var(--accent);
  opacity: 0.6;
}

/* ── Contenido con ancho máximo cómodo en escritorio ── */

@media (min-width: 1500px) {
  .app-shell {
    max-width: 1400px;
  }
}

/* ── Accesibilidad: iOS "reducir transparencia" ── */

@media (prefers-reduced-transparency: reduce) {
  .hero-panel,
  .panel,
  .sticky-bar,
  .toast,
  .app-loader,
  .suggestions,
  th,
  .tab-bar,
  .main-value-card,
  .editor-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--panel-strong);
  }
}

/* ═══════════════════════════════════════════════════════
   CARTERA v10 — tabla de solo lectura + editor-portal
   (bottom sheet móvil / modal escritorio) + menú ⋯
   ═══════════════════════════════════════════════════════ */

/* ── Tarjeta superior de Cartera ── */
.cartera-summary {
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line-accent);
  background:
    radial-gradient(ellipse 90% 100% at 0% 0%, rgba(62, 255, 168, 0.08), transparent 60%),
    var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(28px) saturate(175%);
  -webkit-backdrop-filter: blur(28px) saturate(175%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}

.cartera-sum-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cartera-sum-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.cartera-sum-value {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 6vw, 1.9rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.cartera-sum-pnl {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.cartera-sum-pnl strong { display: block; font-size: 1rem; font-weight: 700; }
.cartera-sum-pnl span { font-size: 0.8rem; }
.cartera-sum-pnl.positive { color: var(--positive); }
.cartera-sum-pnl.negative { color: var(--negative); }

.cartera-sum-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}

.cartera-sum-updated { margin-left: auto; }

.cartera-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.cartera-toolbar .mobile-sort {
  margin-bottom: 0;
  max-width: 340px;
  width: 100%;
}

/* ── Tabla de solo lectura (escritorio) ── */
.col-price, .col-invested, .col-value, .col-pnl { text-align: right; }
th.col-price .th-shell, th.col-invested .th-shell,
th.col-value .th-shell, th.col-pnl .th-shell { justify-content: flex-end; }
th.col-actions .th-shell { justify-content: center; }

.portfolio-row { cursor: pointer; }
.portfolio-row:hover td { background: rgba(255, 255, 255, 0.03); }
:root[data-theme="light"] .portfolio-row:hover td { background: rgba(10, 28, 50, 0.03); }

.asset-cell .asset-field {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  text-align: left;
}

.asset-id { min-width: 0; }
.asset-id strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-id small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-dot { color: var(--warning); font-size: 0.8rem; }

.stack-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.stack-cell .money, .stack-cell .numeric { font-variant-numeric: tabular-nums; }
.stack-cell small { color: var(--muted-2); font-weight: 400; }

.quote-time { font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted-2); }
.quote-time.is-stale { color: var(--warning); }

.weight-chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.edit-btn {
  min-height: 34px;
  padding: 0 14px;
  border-color: var(--line-strong);
  color: var(--text-2);
  font-weight: 700;
}

.ghost-icon {
  min-height: 34px;
  width: 34px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

/* ── Estado vacío de posiciones ── */
.empty-positions strong { font-size: 1rem; }
.empty-positions p { color: var(--muted); font-size: 0.85rem; max-width: 320px; }
.empty-positions .primary-btn { margin-top: 6px; }

/* ── Tarjetas de posición (móvil ≤768) ── */
@media (max-width: 768px) {
  .table-wrap { border: none; background: none; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody,
  .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }

  .table-wrap .portfolio-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "asset   value"
      "price   pnl"
      "actions actions";
    gap: 8px 12px;
    align-items: center;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    background: var(--glass-card);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 20px rgba(1, 6, 14, 0.2);
  }
  :root[data-theme="light"] .table-wrap .portfolio-row {
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 4px 14px rgba(14, 40, 70, 0.07);
  }
  .table-wrap .portfolio-row.row-profit { border-left: 3px solid rgba(62, 255, 168, 0.5); }
  .table-wrap .portfolio-row.row-loss { border-left: 3px solid rgba(255, 85, 85, 0.45); }

  .table-wrap .portfolio-row td { padding: 0; text-align: left; }
  .table-wrap .portfolio-row td::before { content: none; }

  /* Cabecera: avatar + nombre a la izquierda, valor + peso a la derecha */
  .portfolio-row .asset-cell { grid-area: asset; display: flex; align-items: center; min-width: 0; }
  .portfolio-row .asset-cell .asset-field { gap: 10px; }
  .portfolio-row .asset-avatar { width: 34px; height: 34px; }

  .portfolio-row .value-col { grid-area: value; text-align: right; }
  .portfolio-row .value-col .stack-cell { align-items: flex-end; }
  .portfolio-row .value-col .money { font-size: 1rem; }

  /* Segunda fila: precio + 24h a la izquierda, PnL a la derecha */
  .portfolio-row .price-col { grid-area: price; }
  .portfolio-row .price-col .stack-cell { align-items: flex-start; }
  .portfolio-row .pnl-col { grid-area: pnl; text-align: right; }
  .portfolio-row .pnl-col .stack-cell { align-items: flex-end; }

  /* Invertido no cabe en la tarjeta: vive en el editor
     (!important neutraliza reglas de tarjeta de iteraciones anteriores) */
  .table-wrap .portfolio-row .invested-col { display: none !important; }

  /* Acciones a lo ancho */
  .table-wrap .portfolio-row .actions-cell { grid-area: actions; display: block !important; }
  .portfolio-row .row-actions { justify-content: stretch; padding-top: 8px; border-top: 1px solid var(--line); }
  .portfolio-row .edit-btn { flex: 1; min-height: 42px; }
  .portfolio-row .ghost-icon { min-height: 42px; width: 46px; }

  .cartera-toolbar .mobile-sort { max-width: 100%; }
  .cartera-sum-updated { margin-left: 0; width: 100%; }

  /* Totales como tarjeta compacta */
  .table-wrap .totals-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line-accent);
    background: var(--glass-card);
  }
  .table-wrap .totals-row td { width: auto; padding: 0; }
  .table-wrap .totals-row .col-price, .table-wrap .totals-row .col-actions { display: none; }
}

/* ── Editor-portal (bottom sheet móvil / modal escritorio) ── */
.editor-portal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
}
.editor-portal[hidden] { display: none; }

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 16, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.2s ease;
}

.editor-panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(560px, calc(100% - 32px));
  max-height: min(90dvh, 780px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  background: var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(36px) saturate(185%);
  -webkit-backdrop-filter: blur(36px) saturate(185%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 30px 80px rgba(1, 6, 14, 0.55);
  animation: editorPop 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: auto;
}

@keyframes editorPop {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.editor-portal.is-closing .editor-panel { animation: editorOut 0.2s ease forwards; }
.editor-portal.is-closing .editor-backdrop { animation: fadeOut 0.2s ease forwards; }
@keyframes editorOut { to { transform: translateY(12px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

.editor-head {
  padding: 14px 18px 6px;
  border-bottom: 1px solid var(--line);
}
.editor-grip { display: none; }
.editor-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.editor-title-row h2 { font-size: 1.05rem; }

.editor-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor-field { position: relative; display: flex; flex-direction: column; gap: 6px; }
.editor-field > span {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}
.editor-field input,
.editor-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(5, 12, 22, 0.5);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}
:root[data-theme="light"] .editor-field input,
:root[data-theme="light"] .editor-field textarea {
  background: rgba(255, 255, 255, 0.8);
}
.editor-field textarea { min-height: 60px; resize: vertical; font-family: var(--font-body); font-weight: 400; }
.editor-field input:focus, .editor-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 255, 168, 0.14);
}

.editor-readonly {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}
.editor-readonly strong { font-family: var(--font-mono); font-size: 0.95rem; }

.editor-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-tp-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.editor-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.9rem;
}
.editor-check input { width: 20px; height: 20px; accent-color: var(--accent); }

.editor-hint, .editor-secondary { font-size: 0.72rem; color: var(--muted); }
.editor-hint { margin-top: 2px; }

.editor-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.editor-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.editor-suggestion:hover { background: var(--panel-hover); }
.editor-suggestion img { width: 24px; height: 24px; border-radius: 50%; }
.editor-suggestion span { flex: 1; min-width: 0; }
.editor-suggestion strong { display: block; font-size: 0.85rem; }
.editor-suggestion small { color: var(--muted); font-family: var(--font-mono); font-size: 0.7rem; }
.editor-suggestion-rank { color: var(--muted-2); font-family: var(--font-mono); font-size: 0.68rem; }

.editor-foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.editor-foot .ghost-btn { flex: 0 0 auto; }
.editor-foot .primary-btn { flex: 1; min-height: 48px; }

/* Móvil: el editor sube desde abajo como bottom sheet */
@media (max-width: 768px) {
  .editor-panel {
    margin: auto 0 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .editor-portal.is-closing .editor-panel { animation: sheetDown 0.22s ease forwards; }
  @keyframes sheetDown { to { transform: translateY(100%); } }
  .editor-grip {
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: rgba(150, 175, 200, 0.4);
    margin: 0 auto 10px;
  }
}

/* ── Menú contextual de fila ── */
.row-context-menu {
  position: fixed;
  z-index: 210;
  width: 190px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--panel-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  animation: fadeIn 0.14s ease;
}
.row-context-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.row-context-menu button:hover { background: var(--panel-hover); }
.row-context-menu button.danger { color: var(--danger); }
.row-context-menu button:disabled { opacity: 0.4; cursor: not-allowed; }

body.editor-open { overflow: hidden; }

/* ═══════════════════════════════════════════════════════
   NAV v11 — dock de 5 con botón central "+" y su sheet
   ═══════════════════════════════════════════════════════ */

.tab-bar { grid-template-columns: repeat(5, 1fr); }

.tab-fab {
  position: relative;
  background: none !important;
  overflow: visible;
}
.tab-fab .tab-fab-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(150deg, var(--accent-2), #8f79ff);
  box-shadow: 0 8px 22px rgba(90, 120, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.16s ease;
}
.tab-fab .tab-fab-circle svg { width: 24px; height: 24px; }
.tab-fab:active .tab-fab-circle { transform: scale(0.9); }

@media (max-width: 768px) {
  .tab-fab .tab-fab-circle { margin-top: -22px; }
}
@media (min-width: 769px) {
  .tab-fab { min-height: 44px; }
  .tab-fab .tab-fab-circle { width: 40px; height: 40px; }
  .tab-fab .tab-fab-circle svg { width: 20px; height: 20px; }
}

/* ── Bottom sheet del botón "+" ── */
.fab-sheet {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.fab-sheet[hidden] { display: none; }

.fab-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 16, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.2s ease;
}

.fab-sheet-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  margin: 0 auto;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--glass-border);
  border-bottom: none;
  background: var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(36px) saturate(185%);
  -webkit-backdrop-filter: blur(36px) saturate(185%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 -20px 60px rgba(1, 6, 14, 0.5);
  animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.fab-sheet.is-closing .fab-sheet-panel { animation: sheetDown 0.2s ease forwards; }
.fab-sheet.is-closing .fab-sheet-backdrop { animation: fadeOut 0.2s ease forwards; }

@media (min-width: 769px) {
  .fab-sheet { align-items: center; }
  .fab-sheet-panel { border-radius: 24px; border-bottom: 1px solid var(--glass-border); animation: editorPop 0.24s ease; }
}

.fab-sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: rgba(150, 175, 200, 0.4);
  margin: 6px auto 4px;
}
.fab-sheet-title { font-size: 1.05rem; margin: 6px 4px 8px; }

.fab-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: var(--glass-card);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, background 0.15s;
}
.fab-option:active { transform: scale(0.98); background: var(--panel-hover); }

.fab-option-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
.fab-option-icon svg { width: 22px; height: 22px; }
.fab-option-icon.accent   { color: var(--accent-2); background: var(--accent-2-dim); }
.fab-option-icon.accent2  { color: #8f79ff; background: rgba(143, 121, 255, 0.14); }
.fab-option-icon.positive { color: var(--positive); background: var(--positive-bg); }
.fab-option-icon.negative { color: var(--negative); background: var(--negative-bg); }
.fab-option-icon.warning  { color: var(--warning); background: var(--warning-bg); }

.fab-option-text { flex: 1; min-width: 0; }
.fab-option-text strong { display: block; font-size: 0.92rem; }
.fab-option-text small { color: var(--muted); font-size: 0.76rem; }
.fab-option-chevron { color: var(--muted-2); font-size: 1.2rem; }

.fab-cancel {
  margin-top: 6px;
  min-height: 50px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.fab-cancel:active { background: var(--panel-hover); }

body.fab-open { overflow: hidden; }

/* En móvil, la toolbar de escritorio (Nueva/Actualizar/Guardar) se oculta:
   sus acciones viven en el botón "+". */
@media (max-width: 768px) {
  .desktop-only-toolbar { display: none; }
}

.compact-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.compact-heading .home-section-title { margin: 0; }
.compact-heading .cartera-toolbar { margin: 0; }

/* ── Pestaña Mercados: ganadores/perdedores ── */
.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}
@media (max-width: 480px) {
  .movers-grid { grid-template-columns: 1fr; }
}
.movers-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.movers-title.positive { color: var(--positive); }
.movers-title.negative { color: var(--negative); }
.mover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.mover-row:last-child { border-bottom: none; }
.mover-row .asset-avatar { width: 26px; height: 26px; flex-shrink: 0; }
.mover-name { flex: 1; min-width: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-pct { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.movers-empty { color: var(--muted); font-size: 0.82rem; padding: 8px 0; }

/* ═══════════════════════════════════════════════════════
   DETALLE DE ACTIVO v12 — pantalla completa con pestañas
   ═══════════════════════════════════════════════════════ */

.asset-detail {
  position: fixed;
  inset: 0;
  z-index: 180;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  animation: detailIn 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
.asset-detail[hidden] { display: none; }
.asset-detail.is-closing { animation: detailOut 0.2s ease forwards; }
@keyframes detailIn { from { transform: translateX(6%); opacity: 0.4; } to { transform: translateX(0); opacity: 1; } }
@keyframes detailOut { to { transform: translateX(6%); opacity: 0; } }

.detail-inner {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px calc(90px + env(safe-area-inset-bottom));
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0 12px;
}
.detail-head-id {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.detail-head-id .asset-avatar { width: 30px; height: 30px; }
.detail-head-id strong { display: block; font-size: 0.95rem; }
.detail-head-id small { display: block; font-size: 0.72rem; color: var(--muted); }
.detail-head-actions { display: flex; gap: 8px; }
.icon-circle-btn.is-fav { color: var(--warning); border-color: rgba(255, 201, 71, 0.4); }

.detail-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.detail-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.detail-price-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-price {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-body { flex: 1; }

.detail-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
@media (max-width: 420px) { .detail-cards { grid-template-columns: repeat(2, 1fr); } }
.detail-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  min-width: 0;
}
.detail-card span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.detail-card strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-card small { font-family: var(--font-mono); font-size: 0.72rem; }

.detail-chart-block {
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  border-radius: 18px;
  padding: 14px;
}
.detail-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.detail-chart-head h3 { font-size: 0.9rem; }
.detail-range { display: flex; gap: 4px; flex-wrap: wrap; }
.detail-range-chip {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}
.detail-range-chip.is-active { color: var(--accent); border-color: rgba(62,255,168,0.35); background: var(--accent-dim); }
.detail-chart svg { width: 100%; height: 140px; display: block; }
.detail-chart-axis { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted-2); margin-top: 4px; }
.detail-chart-empty, .detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.detail-history { display: flex; flex-direction: column; gap: 8px; }
.detail-history-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
}
.detail-history-item strong { display: block; font-size: 0.85rem; }
.detail-history-item p { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.detail-history-item time { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted-2); margin-top: 6px; }

.detail-targets, .detail-alerts { display: flex; flex-direction: column; gap: 12px; }
.detail-target {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
}
.detail-target.reached { border-color: var(--line-accent); }
.detail-target-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-family: var(--font-mono); font-size: 0.82rem; }
.detail-target em { color: var(--muted-2); font-style: normal; }
.detail-target .tp-progress { height: 6px; }

.detail-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
}
.detail-alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warning); flex-shrink: 0; box-shadow: 0 0 8px var(--warning); }
.detail-alert-dot.fired { background: var(--positive); box-shadow: 0 0 8px var(--positive); }

.detail-notes { display: flex; flex-direction: column; gap: 12px; }
.detail-note-meta { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 10px 12px; border-radius: 12px; background: var(--panel-soft); }
.detail-note-meta span { color: var(--muted); }
.detail-note-text { padding: 14px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-card); line-height: 1.6; font-size: 0.9rem; }

.detail-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 1px solid var(--glass-border);
}
.detail-foot-btn {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.12s;
}
.detail-foot-btn:active { transform: scale(0.96); }
.detail-foot-btn.buy { background: linear-gradient(135deg, #3effa8, #22d98a); color: #030d0a; border-color: transparent; font-weight: 700; }
.detail-foot-btn.sell { background: rgba(255,85,85,0.14); border-color: rgba(255,85,85,0.3); color: #ffb8b8; }

body.detail-open { overflow: hidden; }

/* ═══════════════════════════════════════════════════════
   MERCADOS v13 — buscador, pestañas, ranking y paginación
   ═══════════════════════════════════════════════════════ */

.markets-ranking-panel { display: flex; flex-direction: column; gap: 12px; }

.markets-search {
  position: relative;
  display: flex;
  align-items: center;
}
.markets-search svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.markets-search input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 42px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(5, 12, 22, 0.5);
  color: var(--text);
  font-size: 16px;
}
:root[data-theme="light"] .markets-search input { background: rgba(255,255,255,0.8); }
.markets-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62,255,168,0.14); }

/* ── Tabla general de mercado (única, ordenable, cabecera fija) ── */
.markets-ranking { display: block; }
.markets-table-wrap {
  overflow: auto;
  max-height: 68vh;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.markets-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.markets-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-3);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  text-align: right;
  user-select: none;
}
.markets-table thead th.mk-rank,
.markets-table thead th.mk-asset { text-align: left; }
.markets-table th.mk-sortable { cursor: pointer; }
.markets-table th.mk-sortable:hover { color: var(--text-2); }
.markets-table th.mk-sortable span { display: inline-flex; align-items: center; gap: 4px; }
.markets-table th.is-sorted { color: var(--accent); }
.mk-arrow { font-style: normal; font-size: 0.7em; }

.markets-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: right;
  white-space: nowrap;
}
.mk-row { cursor: pointer; transition: background 0.12s ease; }
.mk-row:hover { background: var(--panel-hover); }
.mk-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mk-row:last-child td { border-bottom: none; }
.markets-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.markets-table td.positive { color: var(--positive); }
.markets-table td.negative { color: var(--negative); }
.markets-table td.neutral { color: var(--muted); }

.markets-table td.mk-rank { text-align: left; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }
.markets-table td.mk-asset { text-align: left; }
.mk-asset { display: flex; align-items: center; gap: 10px; }
.mk-asset .asset-avatar { width: 28px; height: 28px; flex: 0 0 auto; }
.mk-name { min-width: 0; display: flex; flex-direction: column; }
.mk-name strong { font-size: 0.86rem; font-weight: 600; }
.mk-name small { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; }
.rank-owned { color: var(--accent); font-style: normal; font-size: 0.7em; }

.mk-perf { width: 92px; }
.mk-spark { display: block; width: 80px; height: 24px; margin-left: auto; }
.mk-spark.positive { color: var(--positive); }
.mk-spark.negative { color: var(--negative); }
.mk-spark.neutral { color: var(--neutral); }
.mk-spark-empty { color: var(--muted-2); font-family: var(--font-mono); font-size: 0.75rem; }

.markets-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 6px;
}
.pag-btn {
  min-width: 44px;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.pag-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pag-info { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }

.markets-skeleton { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.markets-skeleton .skeleton-line { height: 34px; width: 100%; }

/* ═══════════════════════════════════════════════════════
   ANALITICA v14 — sub-pestañas y bloques
   ═══════════════════════════════════════════════════════ */

.sub-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.sub-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.atab-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: tabIn 0.2s ease;
}
.atab-group[hidden] { display: none; }

/* Analítica unificada: todos los bloques en una sola vista */
.analytics-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: tabIn 0.2s ease;
}

/* Compra/venta: tokens calculados (dato informativo) */
.trade-calc {
  min-height: 1.2em;
  color: var(--muted);
}
.trade-calc strong { color: var(--accent); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.trade-calc strong.positive { color: var(--positive); }
.trade-calc strong.negative { color: var(--negative); }

/* Venta rápida: atajos de porcentaje del valor de la posición */
.trade-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 2px; }
.trade-quick .chip-preset { min-height: 40px; padding: 0 14px; }

/* Mejor / peor */
.best-worst-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bw-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bw-card > span {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}
.bw-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bw-main .asset-avatar { width: 26px; height: 26px; }
.bw-main strong { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bw-pct { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Comparativa vs BTC/ETH */
.compare-block { display: flex; flex-direction: column; gap: 12px; }
.compare-row { display: grid; grid-template-columns: 90px 1fr 64px; align-items: center; gap: 10px; }
.compare-row.is-accent .compare-label { color: var(--accent); font-weight: 700; }
.compare-label { font-size: 0.8rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-bar { height: 10px; border-radius: 99px; background: rgba(120,150,180,0.14); overflow: hidden; }
.compare-bar span { display: block; height: 100%; border-radius: 99px; }
.compare-bar span.positive { background: var(--positive); }
.compare-bar span.negative { background: var(--negative); }
.compare-pct { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* Categoría y concentración */
.category-block, .concentration-block { display: flex; flex-direction: column; gap: 12px; }
.category-row, .conc-row { display: grid; grid-template-columns: 110px 1fr 52px; align-items: center; gap: 10px; }
.category-label { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; }
.category-label i { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.category-bar { height: 10px; border-radius: 99px; background: rgba(120,150,180,0.14); overflow: hidden; }
.category-bar span { display: block; height: 100%; border-radius: 99px; background: var(--accent-2); }
.category-row strong, .conc-row strong { font-family: var(--font-mono); font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; }
.conc-row span:first-child { font-size: 0.82rem; color: var(--text-2); }

/* Riesgo */
.risk-block { display: flex; flex-direction: column; gap: 16px; }
.risk-gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.risk-gauge {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.risk-gauge span { font-family: var(--font-mono); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--muted); }
.risk-gauge > strong { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; }
.risk-gauge small { font-size: 0.72rem; color: var(--muted); }
.risk-gauge .tp-progress { height: 6px; margin-top: 2px; }
.risk-list-block { display: flex; flex-direction: column; gap: 8px; }

/* ═══════════════════════════════════════════════════════
   FILTROS v15 — botón y panel de filtros de la tabla
   (sin cambios en la navegación ni columnas: se mantiene
   el aspecto original)
   ═══════════════════════════════════════════════════════ */

/* ── Botón Filtros de la tabla ── */
.cartera-toolbar { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.filters-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; position: relative; }
.filters-btn svg { width: 16px; height: 16px; }
.filters-count {
  min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent); color: #041008;
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700;
}

/* ── Cajón de filtros (drawer derecho / bottom sheet móvil) ── */
.filters-drawer { position: fixed; inset: 0; z-index: 195; display: flex; justify-content: flex-end; }
.filters-drawer[hidden] { display: none; }
.filters-backdrop { position: absolute; inset: 0; background: rgba(2,8,16,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn 0.2s ease; }
.filters-panel {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--glass-border);
  background: var(--glass-inner), var(--glass-bg-strong);
  backdrop-filter: blur(36px) saturate(185%);
  -webkit-backdrop-filter: blur(36px) saturate(185%);
  box-shadow: -20px 0 60px rgba(1,6,14,0.5);
  animation: drawerIn 0.26s cubic-bezier(0.32,0.72,0,1);
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.filters-drawer.is-closing .filters-panel { animation: drawerOut 0.2s ease forwards; }
@keyframes drawerOut { to { transform: translateX(100%); } }
.filters-drawer.is-closing .filters-backdrop { animation: fadeOut 0.2s ease forwards; }

.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.filters-head h2 { font-size: 1.05rem; }
.filters-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.filter-field { display: flex; flex-direction: column; gap: 8px; }
.filter-field > span { font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--muted); }
.filter-field > span strong { color: var(--accent); }
.filter-field select {
  min-height: 46px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px;
}
:root[data-theme="light"] .filter-field select { background: rgba(255,255,255,0.8); }
.filter-field input[type="range"] { width: 100%; accent-color: var(--accent); height: 24px; }
.filter-toggle { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 0.9rem; cursor: pointer; }
.filter-toggle input { width: 44px; height: 26px; accent-color: var(--accent); }
.filters-foot { display: flex; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.filters-foot .ghost-btn { flex: 0 0 auto; }
.filters-foot .primary-btn { flex: 1; min-height: 48px; }

body.filters-open { overflow: hidden; }

/* Móvil: el cajón sube desde abajo */
@media (max-width: 768px) {
  .filters-drawer { align-items: flex-end; justify-content: stretch; }
  .filters-panel {
    width: 100%;
    height: auto;
    max-height: 86dvh;
    border-left: none;
    border-radius: 24px 24px 0 0;
    animation: sheetUp 0.28s cubic-bezier(0.32,0.72,0,1);
  }
  @keyframes drawerOut { to { transform: translateY(100%); } }
  .filters-drawer.is-closing .filters-panel { animation: sheetDown 0.2s ease forwards; }
}

/* ═══════════════════════════════════════════════════════
   PLAN v16 — acciones rápidas y pestaña de rebalanceo
   ═══════════════════════════════════════════════════════ */

/* Acciones rápidas (Inicio) */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-card);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.quick-action:active { transform: scale(0.95); background: var(--panel-hover); }
.qa-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.qa-icon svg { width: 20px; height: 20px; }
.qa-icon.accent { color: var(--accent-2); background: var(--accent-2-dim); }
.qa-icon.accent2 { color: #8f79ff; background: rgba(143,121,255,0.14); }
.qa-icon.positive { color: var(--positive); background: var(--positive-bg); }
.qa-icon.negative { color: var(--negative); background: var(--negative-bg); }

/* Pestaña Plan */
.plan-empty { padding: 40px 20px; }
[data-tab="plan"] > #planContent { display: flex; flex-direction: column; gap: 12px; }
[data-tab="plan"] .panel { display: flex; flex-direction: column; gap: 12px; }

.plan-goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan-progress-bar {
  height: 12px; border-radius: 99px; overflow: hidden;
  background: rgba(120,150,180,0.16);
}
.plan-progress-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.plan-progress-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); flex-wrap: wrap; }
.plan-hint { font-size: 0.76rem; color: var(--muted); line-height: 1.5; }

.plan-sum { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.plan-sum.ok { color: var(--positive); background: var(--positive-bg); }
.plan-sum.warn { color: var(--warning); background: var(--warning-bg); }
.plan-strategy-actions { display: flex; gap: 8px; }
.plan-strategy-actions .ghost-btn { min-height: 38px; }

.plan-strategy-list { display: flex; flex-direction: column; gap: 8px; }
.strategy-row { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-card); }
.strategy-row.is-excluded { opacity: 0.55; }
.strategy-main { display: flex; align-items: center; gap: 10px; }
.strategy-main .asset-avatar { width: 28px; height: 28px; flex-shrink: 0; }
.strategy-id { flex: 1; min-width: 0; }
.strategy-id strong { display: block; font-size: 0.85rem; }
.strategy-id small { display: block; font-size: 0.7rem; color: var(--muted); }
.st-under { color: var(--accent-2); } .st-over { color: var(--warning); } .st-on { color: var(--positive); }
.strategy-weight { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.strategy-weight input { width: 60px; min-height: 40px; text-align: right; padding: 0 8px; border-radius: 10px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-family: var(--font-mono); font-size: 16px; }
:root[data-theme="light"] .strategy-weight input { background: rgba(255,255,255,0.8); }
.strategy-weight span { color: var(--muted); font-family: var(--font-mono); }
.strategy-adv { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.strategy-adv label { display: flex; align-items: center; gap: 4px; font-size: 0.66rem; color: var(--muted); font-family: var(--font-mono); }
.strategy-adv label input { width: 48px; min-height: 34px; text-align: right; padding: 0 6px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; }
:root[data-theme="light"] .strategy-adv label input { background: rgba(255,255,255,0.8); }
.strategy-toggle { min-height: 34px; min-width: 40px; border-radius: 10px; border: 1px solid var(--glass-border); background: var(--panel-soft); color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.strategy-toggle.is-on { color: var(--positive); border-color: rgba(62,255,168,0.3); }
.strategy-toggle.is-lock { color: var(--warning); border-color: rgba(255,201,71,0.3); }

.plan-amount-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.plan-amount-field { flex: 1; min-width: 130px; }
.plan-amount-field input { min-height: 48px; font-size: 18px; font-family: var(--font-mono); }
.plan-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-preset { min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--glass-border); background: var(--glass-card); color: var(--text-2); font-family: var(--font-mono); font-weight: 700; cursor: pointer; }
.chip-preset:active { transform: scale(0.95); }
.plan-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.plan-mode { min-height: 42px; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--glass-card); color: var(--muted); font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.plan-mode.is-active { color: var(--accent); border-color: rgba(62,255,168,0.35); background: var(--accent-dim); }
.plan-adv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-calc-btn { min-height: 50px; }

.plan-result { display: flex; flex-direction: column; gap: 12px; }
.plan-result:empty { display: none; }
.plan-result-head strong { display: block; font-size: 1rem; }
.plan-result-head span { font-size: 0.8rem; color: var(--muted); }
.plan-alloc-list { display: flex; flex-direction: column; gap: 8px; }
.plan-alloc { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-card); }
.plan-alloc.is-zero { opacity: 0.6; }
.plan-alloc-top { display: flex; align-items: center; gap: 10px; }
.plan-alloc-top .asset-avatar { width: 26px; height: 26px; flex-shrink: 0; }
.plan-alloc-name { flex: 1; min-width: 0; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-alloc-amount { font-family: var(--font-mono); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.plan-alloc-weights { display: flex; gap: 12px; margin-top: 6px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.plan-alloc-target { margin-left: auto; }
.plan-alloc-why { margin-top: 6px; font-size: 0.74rem; color: var(--muted); line-height: 1.5; }
.plan-summary { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--panel-soft); }
.plan-summary div { display: flex; justify-content: space-between; font-size: 0.82rem; }
.plan-summary strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.plan-result-actions { display: flex; gap: 10px; }
.plan-result-actions .ghost-btn { flex: 0 0 auto; }
.plan-result-actions .primary-btn { flex: 1; min-height: 48px; }
.plan-disclaimer { font-size: 0.7rem; color: var(--muted-2); line-height: 1.5; text-align: center; padding: 0 8px; }
.plan-disclaimer.small { text-align: left; margin-top: 4px; }

/* Rebalanceo completo y simulador */
.sim-inputs { display: flex; flex-direction: column; gap: 10px; }
.sim-inputs select, .sim-inputs input {
  min-height: 46px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5);
  color: var(--text); font-size: 16px;
}
:root[data-theme="light"] .sim-inputs select, :root[data-theme="light"] .sim-inputs input { background: rgba(255,255,255,0.8); }
.plan-sim-card select#simType { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; }
:root[data-theme="light"] .plan-sim-card select#simType { background: rgba(255,255,255,0.8); }

/* Planes DCA */
.dca-list { display: flex; flex-direction: column; gap: 8px; }
.dca-plan { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-card); }
.dca-plan.is-due { border-color: var(--line-accent); box-shadow: 0 0 0 1px rgba(62,255,168,0.15); }
.dca-plan-main { flex: 1; min-width: 0; }
.dca-plan-main strong { display: block; font-size: 0.86rem; }
.dca-plan-main small { display: block; font-size: 0.72rem; color: var(--muted); }
.dca-plan-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.dca-plan-actions .ghost-btn { min-height: 36px; padding: 0 12px; }
.dca-plan-actions .icon-btn { min-height: 36px; width: 36px; padding: 0; }
.dca-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dca-form select, .dca-form input { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; }
:root[data-theme="light"] .dca-form select, :root[data-theme="light"] .dca-form input { background: rgba(255,255,255,0.8); }

/* ═══════════════════════════════════════════════════════
   HERRAMIENTAS v17 — rebalanceo con aportacion + simulador TP
   ═══════════════════════════════════════════════════════ */
#planSubContent { display: flex; flex-direction: column; gap: 12px; }
#planSubContent .panel { display: flex; flex-direction: column; gap: 12px; }
.reb-strats .plan-mode { font-size: 0.82rem; }

.risk-badge { font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 99px; }
.risk-low { color: var(--positive); background: var(--positive-bg); border: 1px solid rgba(62,255,168,0.3); }
.risk-medium { color: var(--warning); background: var(--warning-bg); border: 1px solid rgba(255,201,71,0.3); }
.risk-high { color: var(--negative); background: var(--negative-bg); border: 1px solid rgba(255,85,85,0.3); }

.reb-summary { padding: 14px; border-radius: 16px; border: 1px solid var(--line-accent); background: var(--glass-card); display: flex; flex-direction: column; gap: 10px; }
.reb-sum-top { display: flex; align-items: center; justify-content: space-between; }
.reb-sum-top strong { font-size: 0.95rem; }
.reb-sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.reb-sum-grid > div { display: flex; flex-direction: column; }
.reb-sum-grid span { font-family: var(--font-mono); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.reb-sum-grid b { font-family: var(--font-mono); font-size: 0.9rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reb-list { display: flex; flex-direction: column; gap: 8px; }
.reb-item { padding: 12px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-card); }
.reb-item-head { display: flex; align-items: center; gap: 10px; }
.reb-item-head .asset-avatar { width: 28px; height: 28px; flex-shrink: 0; }
.reb-item-name { flex: 1; min-width: 0; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reb-item-amount { font-family: var(--font-mono); font-size: 1rem; font-variant-numeric: tabular-nums; }
.reb-item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; }
.reb-item-grid > div { display: flex; flex-direction: column; min-width: 0; }
.reb-item-grid span { font-family: var(--font-mono); font-size: 0.56rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.reb-item-grid b { font-family: var(--font-mono); font-size: 0.78rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reb-weightbar { position: relative; height: 8px; margin-top: 10px; border-radius: 99px; background: rgba(120,150,180,0.14); overflow: hidden; }
.reb-weightbar .wb-before { position: absolute; left: 0; top: 0; height: 100%; background: rgba(120,150,180,0.5); border-radius: 99px; }
.reb-weightbar .wb-after { position: absolute; left: 0; top: 0; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; opacity: 0.9; }

.reb-compare { margin-top: 4px; display: flex; flex-direction: column; gap: 10px; }
.reb-compare-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.reb-compare-col { padding: 10px; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--glass-card); }
.reb-compare-col.is-active { border-color: var(--accent); }
.reb-compare-body { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.reb-compare-body > div { display: flex; flex-direction: column; }
.reb-compare-body span { font-size: 0.54rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.reb-compare-body b { font-family: var(--font-mono); font-size: 0.78rem; }
.reb-compare-assets { margin-top: 8px; font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); line-height: 1.5; word-break: break-word; }
.reb-compare-notes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.reb-compare-notes b { color: var(--text-2); }
@media (max-width: 520px) { .reb-compare-grid { grid-template-columns: 1fr; } }

.tp-card-head { display: flex; align-items: center; gap: 10px; }
.tp-card-head .asset-avatar { width: 30px; height: 30px; flex-shrink: 0; }
.tp-card-id strong { display: block; font-size: 0.9rem; }
.tp-card-id small { display: block; font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); }
.tp-pcts { display: flex; gap: 8px; flex-wrap: wrap; }
.tp-pcts label { display: flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.tp-pcts input { width: 52px; min-height: 36px; text-align: right; padding: 0 8px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; }
:root[data-theme="light"] .tp-pcts input { background: rgba(255,255,255,0.8); }
.tp-steps { display: flex; flex-direction: column; gap: 8px; }
.tp-step { padding: 10px 12px; border-radius: 12px; background: var(--panel-soft); }
.tp-step-top { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.78rem; }
.tp-step-top strong { color: var(--accent); }
.tp-step-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.tp-step-grid > div { display: flex; flex-direction: column; }
.tp-step-grid span { font-size: 0.54rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.tp-step-grid b { font-family: var(--font-mono); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.tp-summary, .tp-global-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; padding: 12px 14px; border-radius: 14px; background: var(--panel-soft); }
.tp-global-grid { grid-template-columns: repeat(4, 1fr); }
.tp-summary > div, .tp-global-grid > div { display: flex; flex-direction: column; min-width: 0; }
.tp-summary span, .tp-global-grid span { font-size: 0.54rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.tp-summary b, .tp-global-grid b { font-family: var(--font-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-full { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.tp-full-label { font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; color: var(--muted); width: 100%; }
.tp-full > div { display: flex; gap: 6px; font-family: var(--font-mono); font-size: 0.74rem; }
.tp-full b { font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .tp-global-grid { grid-template-columns: repeat(2, 1fr); } }
.tp-global-table { display: flex; flex-direction: column; margin-top: 4px; overflow-x: auto; }
.tpg-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.tpg-row span:not(:first-child) { text-align: right; }
.tpg-head { color: var(--muted); font-weight: 700; }
.tp-card { gap: 12px; }

/* ── Simulador TP: bloques globales, escenarios y config por activo ── */
.tp-block { display: flex; flex-direction: column; gap: 12px; border-left: 3px solid transparent; }
.tp-block-head { display: flex; align-items: flex-start; gap: 10px; }
.tp-block-head h2 { margin: 0; }
.tp-block-head small { display: block; font-size: 0.66rem; color: var(--muted); line-height: 1.35; margin-top: 3px; }
.tp-block-badge { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 0.82rem; color: #04121a; flex-shrink: 0; }
.tp-block-prog { border-left-color: var(--accent); }
.tp-block-prog .tp-block-badge { background: var(--accent); }
.tp-block-full { border-left-color: var(--accent2, #a988ff); }
.tp-block-full .tp-block-badge { background: var(--accent2, #a988ff); }

.tp-table-prog .tpg-exp { text-align: left; font-size: 0.62rem; color: var(--muted); white-space: normal; }
.tp-table-full .tpg-row { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
.tp-table-compare .tpg-row { grid-template-columns: 1.2fr repeat(calc(var(--tp-cols, 5) - 1), minmax(46px, 1fr)); }

.tp-scenarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tp-scenario { padding: 12px 14px; border-radius: 14px; background: var(--panel-soft); display: flex; flex-direction: column; gap: 8px; }
.tp-scenario-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--font-mono); }
.tp-scenario-top strong { font-size: 0.72rem; color: var(--muted); }
.tp-scenario-top b { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.tp-scenario-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.tp-scenario-grid > div { display: flex; flex-direction: column; }
.tp-scenario-grid span { font-size: 0.54rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.tp-scenario-grid b { font-family: var(--font-mono); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.tp-config { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border-radius: 12px; background: var(--panel-soft); max-width: 520px; }
.tp-config-row, .tp-config-legend { display: grid; grid-template-columns: 42px 1fr 74px 26px; gap: 8px; align-items: center; }
.tp-config-legend { font-size: 0.52rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.tp-config-legend span:nth-child(1) { grid-column: 2; }
.tp-config-legend span:nth-child(2) { grid-column: 3; text-align: right; }
.tp-config-del { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--glass-border); background: transparent; color: var(--muted-2); font-size: 0.7rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.tp-config-del:hover { color: #ff6b6b; border-color: rgba(255,107,107,0.4); }
.tp-config-del-spacer { width: 26px; }
.tp-config-row.is-add .tp-config-label { color: var(--muted-2); }
.tp-config-row.is-add .tp-config-price::placeholder { color: var(--muted-2); }
.tp-config-label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); font-weight: 700; }
.tp-config-row.is-optional .tp-config-label { color: var(--muted); }
.tp-config-price, .tp-config-pct input { min-height: 34px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; padding: 0 8px; text-align: right; width: 100%; }
:root[data-theme="light"] .tp-config-price, :root[data-theme="light"] .tp-config-pct input { background: rgba(255,255,255,0.8); }
.tp-config-price-ro { font-family: var(--font-mono); font-size: 0.74rem; text-align: right; color: var(--text); }
.tp-config-price-ro .muted { color: var(--muted-2); font-size: 0.64rem; }
.tp-config-pct { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.tp-config-pct input { width: 52px; }

/* ── Analítica: precio medio y acumulación ── */
.avg-table { display: flex; flex-direction: column; overflow-x: auto; }
.avg-row { display: grid; grid-template-columns: minmax(90px, 1.3fr) 1fr 1fr 0.9fr 0.7fr; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.avg-row > span:not(.avg-asset) { text-align: right; }
.avg-head { color: var(--muted); font-weight: 700; font-size: 0.62rem; text-transform: uppercase; }
.avg-asset { display: flex; align-items: center; gap: 7px; }
.avg-asset .asset-avatar { width: 20px; height: 20px; flex-shrink: 0; }
.avg-hint { grid-column: 1 / -1; font-size: 0.64rem; font-family: var(--font-sans, inherit); color: var(--muted); padding-left: 27px; }
.avg-hint.positive { color: var(--positive, #3effa8); }
.avg-hint.warning { color: #ffb43c; }
@media (max-width: 560px) {
  .avg-row { grid-template-columns: minmax(72px, 1.2fr) 1fr 1fr 0.9fr 0.6fr; font-size: 0.64rem; gap: 5px; }
  .avg-hint { padding-left: 0; }
}

/* ── Analítica: actividad mensual ── */
.acts-block { display: flex; flex-direction: column; gap: 14px; }
.acts-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; padding: 12px 14px; border-radius: 14px; background: var(--panel-soft); }
.acts-totals > div { display: flex; flex-direction: column; }
.acts-totals span { font-size: 0.56rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.acts-totals b { font-family: var(--font-mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.acts-months { display: flex; align-items: flex-end; gap: 10px; padding: 0 4px; }
.acts-month { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.acts-bars { display: flex; align-items: flex-end; gap: 3px; height: 52px; }
.acts-bar { width: 12px; border-radius: 3px 3px 0 0; }
.acts-bar.buy { background: var(--positive, #3effa8); opacity: 0.85; }
.acts-bar.sell { background: #ff7b7b; opacity: 0.85; }
.acts-month small { font-family: var(--font-mono); font-size: 0.58rem; color: var(--muted); }
.acts-legend { display: flex; gap: 14px; font-family: var(--font-mono); font-size: 0.62rem; }
.acts-legend .buy { color: var(--positive, #3effa8); }
.acts-legend .sell { color: #ff7b7b; }

/* ── Diagnóstico (Más) ── */
.diag-panel { padding: 10px 16px; }
.diag-summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; padding: 6px 0; list-style: none; }
.diag-summary::-webkit-details-marker { display: none; }
.diag-summary::after { content: "▾"; margin-left: 8px; opacity: 0.6; }
.diag-details[open] .diag-summary::after { content: "▴"; }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; padding: 10px 0 6px; }
.diag-grid > div { display: flex; flex-direction: column; }
.diag-grid span { font-size: 0.56rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.diag-grid b { font-family: var(--font-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.tp-quick { display: flex; flex-direction: column; gap: 10px; }
.tp-quick-head strong { display: block; font-size: 0.85rem; }
.tp-quick-head small { display: block; font-size: 0.66rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.tp-quick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-quick-field { display: flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.tp-quick-field input { width: 56px; min-height: 36px; text-align: right; padding: 0 8px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(5,12,22,0.5); color: var(--text); font-size: 16px; }
:root[data-theme="light"] .tp-quick-field input { background: rgba(255,255,255,0.8); }
.tp-quick-btn { margin-left: auto; min-height: 38px; padding: 0 16px; }
@media (max-width: 560px) { .tp-quick-btn { margin-left: 0; width: 100%; } }

.tp-step-reached { outline: 1px solid rgba(255,180,60,0.35); }
.tp-reached-tag { font-style: normal; font-size: 0.54rem; text-transform: uppercase; color: #ffb43c; background: rgba(255,180,60,0.14); padding: 1px 5px; border-radius: 5px; }
.tp-warn { color: #ffb43c; }
.tp-notice { border: 1px dashed var(--line); }
.tp-notice strong { font-size: 0.85rem; }
.tp-detail-head { margin: 4px 0 -2px; }
.tp-detail-head h2 { margin: 0; }
.tp-full-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; width: 100%; }
.tp-full-grid > div { display: flex; align-items: baseline; gap: 5px; font-family: var(--font-mono); font-size: 0.72rem; }
.tp-full-grid small { font-size: 0.62rem; }

/* ── Simulador TP en móvil: tablas legibles sin romper el layout ── */
@media (max-width: 560px) {
  /* Bloque 1: la columna Explicacion es repetitiva → se oculta; 4 numéricas legibles */
  .tp-table-prog .tpg-row { grid-template-columns: 34px 1fr 1fr 1fr; gap: 6px; font-size: 0.66rem; white-space: nowrap; }
  .tp-table-prog .tpg-row > :nth-child(5) { display: none; }
  /* Bloque 2: las tarjetas de escenario ya muestran total/beneficio/rentabilidad */
  .tp-block-full .tp-table-full { display: none; }
  .tp-scenarios { grid-template-columns: 1fr; }
  .tp-scenario-top strong, .tp-scenario-top b { white-space: nowrap; }
  /* Bloque 3: matriz activo×TP con scroll horizontal y columnas de ancho fijo */
  .tp-table-compare { align-items: flex-start; }
  .tp-table-compare .tpg-row { grid-template-columns: 48px repeat(calc(var(--tp-cols, 5) - 1), 82px); width: max-content; min-width: 100%; font-size: 0.66rem; white-space: nowrap; }
}

/* ═══════════════════════════════════════════════════════
   MÓVIL — tarjetas de activo y de mercado (≤768px)
   Fuente ÚNICA de datos: mismos cálculos que la tabla de
   escritorio. Sin scroll horizontal. Objetivos táctiles ≥44px.
   Esta es la sección responsive canónica: no depende del
   orden accidental de la cascada.
   ═══════════════════════════════════════════════════════ */

/* Visibilidad escritorio/móvil (una sola fuente de verdad) */
.portfolio-mobile-list,
.market-mobile-list,
.market-mobile-sort,
.markets-load-more { display: none; }

@media (max-width: 768px) {
  /* Portafolio: se oculta la tabla y se muestran las tarjetas */
  .portfolio-desktop-table { display: none; }
  .portfolio-mobile-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

  /* Mercado: se oculta la tabla; tarjetas + orden + "Cargar más" */
  .market-desktop-table { display: none; }
  .market-mobile-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .market-mobile-sort { display: flex; }
  .markets-load-more { display: block; }
  .markets-pagination { display: none; }

  /* Ningún panel/contenedor puede exceder el viewport */
  .panel,
  .table-panel,
  .markets-ranking-panel,
  .markets-ranking,
  .table-wrap { min-width: 0; max-width: 100%; }
}

/* ── Tarjeta de activo del portafolio ── */
.asset-mobile-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
}
.asset-mobile-card.row-profit { border-left: 3px solid var(--positive); }
.asset-mobile-card.row-loss { border-left: 3px solid var(--negative); }

.amc-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.amc-head:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.amc-avatar { width: 34px; height: 34px; flex: 0 0 auto; }
.amc-id { min-width: 0; display: flex; flex-direction: column; }
.amc-name { font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amc-sym { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; }
.amc-value { text-align: right; display: flex; flex-direction: column; min-width: 0; }
.amc-value .money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.95rem; white-space: nowrap; }
.amc-pnl { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.72rem; white-space: nowrap; }
.amc-pnl.positive { color: var(--positive); }
.amc-pnl.negative { color: var(--negative); }
.amc-pnl.neutral { color: var(--muted); }
.amc-chevron { width: 20px; height: 20px; color: var(--muted); transition: transform .25s ease; flex: 0 0 auto; }
.asset-mobile-card.is-expanded .amc-chevron { transform: rotate(180deg); }

.amc-subline {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; padding: 0 12px 10px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.82rem;
}
.amc-price { color: var(--text-2); }
.amc-24h.positive { color: var(--positive); }
.amc-24h.negative { color: var(--negative); }
.amc-24h.neutral { color: var(--muted); }
.amc-24h small { color: var(--muted); font-size: 0.72em; }

/* Acordeón suave sin medir alturas por JS */
.amc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.asset-mobile-card.is-expanded .amc-body { grid-template-rows: 1fr; }
.amc-body-inner { overflow: hidden; min-height: 0; }

.amc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  padding: 10px 12px; margin: 0; border-top: 1px solid var(--line);
}
.amc-grid > div { min-width: 0; }
.amc-grid dt { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }
.amc-grid dd { margin: 2px 0 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.86rem; overflow-wrap: anywhere; }

.amc-tps { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.amc-tp { font-size: 0.7rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); font-family: var(--font-mono); }
.amc-tp.reached { color: var(--positive); border-color: var(--line-accent); background: var(--positive-bg); }
.amc-tp.empty { color: var(--muted); }

.amc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 12px 12px; }
.amc-btn { min-height: 44px; width: 100%; }
.amc-actions .amc-sell { background: var(--negative); border-color: var(--negative); color: #0a0f16; }
.amc-actions .amc-delete { color: var(--negative); border-color: rgba(255, 85, 85, 0.35); }

/* ── Tarjeta de mercado (móvil): cabecera compacta + detalle desplegable ── */
.market-mobile-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  overflow: hidden;
  min-width: 0;
}
.mmi-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 3px 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.mmi-head:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.mmi-rank { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.mmi-head > .asset-avatar { width: 32px; height: 32px; }
.mmi-id { min-width: 0; display: flex; flex-direction: column; }
.mmi-id strong { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmi-id small { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.mmi-main { text-align: right; display: flex; flex-direction: column; min-width: 0; }
.mmi-main strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.mmi-main span { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.68rem; white-space: nowrap; color: var(--muted); }
.mmi-main span.positive { color: var(--positive); }
.mmi-main span.negative { color: var(--negative); }
.mmi-chevron { width: 18px; height: 18px; color: var(--muted); transition: transform .25s ease; }
.market-mobile-item.is-expanded .mmi-chevron { transform: rotate(180deg); }

.mmi-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.market-mobile-item.is-expanded .mmi-body { grid-template-rows: 1fr; }
.mmi-body-inner { overflow: hidden; min-height: 0; }
.mmi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); }
.mmi-grid > div { min-width: 0; }
.mmi-grid dt { font-size: 0.62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }
.mmi-grid dd { margin: 2px 0 0; font-size: 0.84rem; }
.mmi-grid dd.positive { color: var(--positive); }
.mmi-grid dd.negative { color: var(--negative); }
.mmi-open { width: 100%; min-height: 44px; margin: 0 12px 12px; width: calc(100% - 24px); }

/* ── Barra de estado de Mercado (sync + actualizar) ── */
.markets-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; font-size: 0.72rem; color: var(--muted); }
.markets-meta .mm-sync { min-width: 0; overflow-wrap: anywhere; }
.markets-meta .mm-sync.is-cached { color: var(--warning); }
.markets-refresh-btn { min-height: 40px; padding: 0 14px; flex: 0 0 auto; }
.markets-refresh-btn[disabled] { opacity: 0.5; cursor: progress; }

/* ── Control de orden móvil ── */
.market-mobile-sort { align-items: flex-end; gap: 8px; margin-bottom: 4px; min-width: 0; }
.mms-field { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mms-field > span { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mms-field select { min-height: 44px; width: 100%; }
.mms-dir { min-width: 44px; min-height: 44px; flex: 0 0 auto; font-size: 1.1rem; }

.markets-load-more { padding-top: 8px; }
.markets-loadmore-btn { width: 100%; min-height: 44px; }

/* ── Toast con acción "Deshacer" ── */
.toast-undo { display: flex; align-items: center; gap: 12px; }
.toast-undo .toast-content { flex: 1 1 auto; min-width: 0; }
.toast-undo-btn {
  flex: 0 0 auto; min-height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--accent); color: var(--accent);
  background: transparent; font-weight: 700; cursor: pointer;
}
.toast-undo-btn:hover { background: var(--accent-dim); }

@media (prefers-reduced-motion: reduce) {
  .amc-body,
  .amc-chevron { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   TEMA OLED — capa negra profunda sobre el modo oscuro.
   No es #000 plano: mantiene niveles de superficie y
   legibilidad, reduce brillos y satura menos las señales.
   Solo aplica cuando data-theme="dark" + data-oled="on".
   ═══════════════════════════════════════════════════════ */
:root[data-theme="dark"][data-oled="on"] {
  --bg:             #000000;
  --bg-2:           #050708;
  --bg-3:           #0a0d10;
  --panel:          rgba(12, 15, 19, 0.96);
  --panel-strong:   rgba(4, 6, 8, 0.99);
  --panel-soft:     rgba(255, 255, 255, 0.026);
  --panel-hover:    rgba(255, 255, 255, 0.05);
  --line:           rgba(118, 148, 176, 0.13);
  --line-strong:    rgba(118, 148, 176, 0.22);
  --line-accent:    rgba(83, 211, 162, 0.18);
  --text:           #eaf2fb;
  --text-2:         #b4c4d4;
  --muted:          #6a879e;
  --muted-2:        #465a6c;
  --accent:         #33e79a;
  --accent-dim:     rgba(51, 231, 154, 0.1);
  --accent-2:       #5aabff;
  --positive:       #33e79a;
  --negative:       #ff5d5d;
  --positive-bg:    rgba(51, 231, 154, 0.07);
  --negative-bg:    rgba(255, 93, 93, 0.07);
  /* Sin halos en OLED: evita grandes áreas brillantes. */
  --glow-accent:    0 0 0 transparent;
  --glow-blue:      0 0 0 transparent;
  --shadow:         0 24px 60px rgba(0, 0, 0, 0.7);
  --shadow-sm:      0 6px 22px rgba(0, 0, 0, 0.55);
}

/* Superficies con fondo hardcodeado: se ajustan a negro en OLED. */
:root[data-theme="dark"][data-oled="on"] body { background: #000; }
:root[data-theme="dark"][data-oled="on"] .sticky-bar,
:root[data-theme="dark"][data-oled="on"] .tab-bar,
:root[data-theme="dark"][data-oled="on"] .fab-sheet-panel {
  background: rgba(4, 6, 9, 0.92);
}

/* Botón de ajuste OLED: estado activo con acento sutil. */
.oled-toggle.is-active {
  border-color: var(--line-accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--line-accent);
}

/* ═══════════════════════════════════════════════════════
   MODO COMPACTO — densidad apretada para carteras grandes.
   Reduce alturas, espaciado e iconos secundarios; conserva
   objetivos táctiles (cabecera-fila y botones ≥44px) y
   legibilidad. Capa independiente data-density="compact".
   ═══════════════════════════════════════════════════════ */
:root[data-density="compact"] .portfolio-mobile-list { gap: 6px; }
:root[data-density="compact"] .market-mobile-list { gap: 5px; }

/* Tarjeta de posición: cabecera más baja (sigue ≥44px), avatar e
   info secundaria más compactos. */
:root[data-density="compact"] .amc-head { min-height: 46px; padding: 6px 11px; gap: 8px; }
:root[data-density="compact"] .amc-avatar { width: 28px; height: 28px; }
:root[data-density="compact"] .amc-name { font-size: 0.88rem; }
:root[data-density="compact"] .amc-value .money { font-size: 0.88rem; }
:root[data-density="compact"] .amc-subline { padding: 0 11px 7px; font-size: 0.76rem; }
:root[data-density="compact"] .amc-grid { padding: 8px 11px; gap: 6px 10px; }
:root[data-density="compact"] .amc-tps { padding: 0 11px 8px; }

/* Tarjeta de mercado: mismo criterio. */
:root[data-density="compact"] .mmi-head { min-height: 46px; padding: 6px 11px; }
:root[data-density="compact"] .mmi-head > .asset-avatar { width: 28px; height: 28px; }
:root[data-density="compact"] .mmi-id strong { font-size: 0.84rem; }

/* Paneles ligeramente más ajustados en móvil (sin afectar a escritorio). */
@media (max-width: 768px) {
  :root[data-density="compact"] .panel { padding: 13px; }
}

/* ═══════════════════════════════════════════════════════
   TOKENS DE DISEÑO — fuente única para nuevos componentes.
   Los valores reflejan los ya usados en la app (espaciado,
   alturas de control, z-index, duraciones), de modo que se
   pueden adoptar de forma incremental sin regresiones.
   Complementan los tokens de color/radio/sombra de :root.
   ═══════════════════════════════════════════════════════ */
:root {
  /* Escala de espaciado (4-40) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Alturas de control (táctil ≥44) */
  --control-sm: 40px;
  --control-md: 44px;
  --control-lg: 48px;
  --control-xl: 52px;

  /* Anchuras máximas */
  --max-content: 1100px;
  --max-readable: 720px;

  /* Duraciones y curvas (interacción → pantalla → modal) */
  --dur-fast: 130ms;
  --dur-base: 200ms;
  --dur-slow: 280ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);

  /* Capas z-index (coinciden con el apilado real actual) */
  --z-base: 1;
  --z-sticky: 60;
  --z-nav: 80;
  --z-fab: 90;
  --z-overlay: 100;
  --z-sheet: 200;
  --z-toast: 210;

  /* Safe areas como tokens (fallback 0px) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ═══════════════════════════════════════════════════════
   LÍNEA DE PRECIO TP — vista visual de medio, actual y
   objetivos con marcadores alcanzado/pendiente (sección 34).
   ═══════════════════════════════════════════════════════ */
.tp-line { margin: var(--space-1) 0 var(--space-2); }
.tpl-top { position: relative; height: 18px; }
.tpl-now-lbl {
  position: absolute; transform: translateX(-50%); bottom: 0;
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  padding: 1px var(--space-2); border-radius: 999px;
}
.tpl-now-lbl.up { color: var(--positive); background: var(--positive-bg); }
.tpl-now-lbl.down { color: var(--negative); background: var(--negative-bg); }
.tpl-track {
  position: relative; height: 10px; border-radius: 999px;
  background: var(--panel-soft); border: 1px solid var(--line);
}
.tpl-fill {
  position: absolute; top: -1px; bottom: -1px; border-radius: 999px;
  transition: left var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out);
}
.tpl-fill.up { background: linear-gradient(90deg, var(--accent-2-dim), var(--accent)); }
.tpl-fill.down { background: linear-gradient(90deg, var(--negative), var(--negative-bg)); }
.tpl-tp {
  position: absolute; top: 50%; width: 3px; height: 16px;
  transform: translate(-50%, -50%); border-radius: 2px; z-index: 1;
}
.tpl-tp.reached { background: var(--accent); box-shadow: 0 0 6px var(--accent-dim); }
.tpl-tp.pending { background: var(--muted); }
.tpl-entry {
  position: absolute; top: 50%; width: 10px; height: 10px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--text-2); border-radius: 2px; z-index: 2;
}
.tpl-now {
  position: absolute; top: 50%; width: 12px; height: 12px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 3px var(--panel); z-index: 3;
}
.tpl-below { position: relative; height: 15px; margin-top: var(--space-1); }
.tpl-entry-lbl, .tpl-tp-lbl {
  position: absolute; transform: translateX(-50%); top: 0;
  font-family: var(--font-mono); font-size: 0.56rem; white-space: nowrap;
}
.tpl-entry-lbl { color: var(--text-2); }
.tpl-tp-lbl.reached { color: var(--accent); }
.tpl-tp-lbl.pending { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .tpl-fill { transition: none; } }

/* ═══════════════════════════════════════════════════════
   COMPARADOR DE CAPITALIZACIÓN (Analítica) — calculadora
   financiera premium. Mobile-first, inputs 16px, tokens.
   ═══════════════════════════════════════════════════════ */
.cap-panel { border: 1px solid var(--line-accent); }
.cap-comparator { display: flex; flex-direction: column; gap: var(--space-3); }
.cap-intro { font-size: 0.78rem; color: var(--muted); line-height: 1.45; margin: 0; }

.cap-modes { display: flex; gap: var(--space-1); background: var(--panel-soft); border-radius: var(--radius-sm); padding: 3px; }
.cap-mode {
  flex: 1; min-height: var(--control-md); border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 600;
  cursor: pointer; padding: 0 4px; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.cap-mode.is-active { background: var(--panel-hover); color: var(--text); box-shadow: var(--shadow-sm); }

.cap-field { display: flex; flex-direction: column; gap: 5px; }
.cap-field > span { font-size: 0.6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-family: var(--font-mono); }
.cap-select, .cap-input {
  width: 100%; min-height: var(--control-lg); border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg-3); color: var(--text);
  font-size: 16px; padding: 0 12px;
}
.cap-input { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:root[data-theme="light"] .cap-select, :root[data-theme="light"] .cap-input { background: rgba(255,255,255,0.85); }

.cap-stat { display: flex; align-items: center; gap: var(--space-2); }
.cap-stat .asset-avatar { width: 26px; height: 26px; flex: 0 0 auto; }
.cap-stat-txt { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 0; }
.cap-inport { color: var(--accent); }

.cap-swap-row { display: flex; justify-content: center; }
.cap-swap {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-md); padding: 0 var(--space-4);
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel-soft);
  color: var(--text-2); font: inherit; font-size: 0.72rem; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast);
}
.cap-swap:hover { border-color: var(--line-accent); color: var(--accent); }
.cap-swap:active { transform: scale(0.96); }
.cap-swap svg { width: 18px; height: 18px; }

.cap-presets { display: flex; flex-wrap: wrap; gap: 6px; }

.cap-result { margin-top: var(--space-1); }
.cap-warn { font-size: 0.78rem; color: var(--warning); margin: var(--space-2) 0; }
.cap-card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--panel-hover), var(--panel-soft));
  border: 1px solid var(--line);
}
.cap-card.up { box-shadow: inset 0 1px 0 var(--line-accent); }
.cap-card-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cap-card-head .asset-avatar { width: 28px; height: 28px; flex: 0 0 auto; }
.cap-card-head strong { font-size: 0.85rem; }
.cap-arrow { color: var(--muted); font-size: 1.1rem; }
.cap-card-main { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.cap-card-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-family: var(--font-mono); width: 100%; }
.cap-big { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.75rem; font-weight: 700; line-height: 1.05; }
.cap-chip { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.cap-chip.positive { color: var(--positive); background: var(--positive-bg); }
.cap-chip.negative { color: var(--negative); background: var(--negative-bg); }
.cap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); }
.cap-grid > div { display: flex; flex-direction: column; min-width: 0; }
.cap-grid span { font-size: 0.56rem; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.cap-grid b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap-note, .cap-impact-line { font-size: 0.7rem; color: var(--muted); line-height: 1.4; margin: 0; }

.cap-impact {
  margin-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-md); background: var(--panel-soft);
  border: 1px solid var(--line);
}
.cap-impact-head strong { font-size: 0.85rem; }
.cap-impact-line b { color: var(--text); }
.cap-impact-bars { display: flex; flex-direction: column; gap: 6px; }
.cap-bar-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); }
.cap-bar { height: 8px; border-radius: 999px; background: var(--panel-hover); overflow: hidden; }
.cap-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--muted); transition: width var(--dur-base) var(--ease-out); }
.cap-bar > span.scenario { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

@media (min-width: 720px) {
  .cap-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .cap-bar > span, .cap-mode, .cap-swap { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   RESUMEN DE RENDIMIENTO (rediseño) — un número dominante,
   contexto temporal, ≤3 secundarias y desglose plegable.
   ═══════════════════════════════════════════════════════ */
.analytics-summary-grid { display: block; }
.as-clean { display: flex; flex-direction: column; gap: var(--space-4); }

.as-period-row { display: flex; flex-wrap: wrap; gap: 4px; background: var(--panel-soft); border-radius: var(--radius-sm); padding: 3px; }
.as-period {
  flex: 1 1 auto; min-width: 44px; min-height: 34px; border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 600;
  font-family: var(--font-mono); cursor: pointer; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
}
.as-period.is-active { background: var(--panel-hover); color: var(--text); box-shadow: var(--shadow-sm); }

.as-hero { display: flex; flex-direction: column; gap: 4px; }
.as-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: var(--font-mono); }
.as-hero-main { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.as-main { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 2.1rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; }
.as-main.muted { color: var(--muted); }
.as-main.positive, .as-main-pct.positive { color: var(--positive); }
.as-main.negative, .as-main-pct.negative { color: var(--negative); }
.as-main-pct { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--panel-soft); }
.as-phrase { font-size: 0.76rem; color: var(--muted); line-height: 1.4; margin: 2px 0 0; }

.as-secondary { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2) var(--space-3); }
.as-sec { display: flex; flex-direction: column; min-width: 0; }
.as-sec span { font-size: 0.56rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-family: var(--font-mono); }
.as-sec b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-sec.muted b { color: var(--text-2); font-weight: 500; }

.as-breakdown { border-top: 1px solid var(--line); padding-top: var(--space-2); }
.as-breakdown > summary {
  list-style: none; cursor: pointer; font-size: 0.72rem; font-weight: 600; color: var(--accent);
  font-family: var(--font-mono); min-height: 34px; display: flex; align-items: center; gap: 6px;
}
.as-breakdown > summary::-webkit-details-marker { display: none; }
.as-breakdown > summary::after { content: "▾"; opacity: .6; transition: transform var(--dur-fast); }
.as-breakdown[open] > summary::after { transform: rotate(180deg); }
.as-bd-grid { display: flex; flex-direction: column; gap: 6px; padding: var(--space-2) 0 4px; }
.as-bd-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); font-family: var(--font-mono); font-size: 0.76rem; }
.as-bd-row > span { color: var(--muted); }
.as-bd-row > b { font-variant-numeric: tabular-nums; }
.as-bd-row > b.positive { color: var(--positive); }
.as-bd-row > b.negative { color: var(--negative); }

.as-empty { padding: var(--space-6) var(--space-2); text-align: center; }
.as-empty p { color: var(--muted); font-size: 0.85rem; margin: 0; }

@media (max-width: 360px) {
  .as-main { font-size: 1.8rem; }
  .as-secondary { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .as-period, .as-breakdown > summary::after { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   ANALÍTICA: subpestañas (Mi portafolio / Comparativas /
   Herramientas) + bloque "Origen del rendimiento".
   ═══════════════════════════════════════════════════════ */
.asub-nav {
  position: sticky; top: max(6px, var(--safe-top));
  z-index: var(--z-sticky);
  display: flex; gap: 4px; padding: 4px;
  margin: 0 0 var(--space-3);
  background: var(--panel-strong); border: 1px solid var(--line);
  border-radius: var(--radius-md); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.asub-tab {
  flex: 1; min-height: var(--control-md); border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
}
.asub-tab.is-active { background: var(--panel-hover); color: var(--text); box-shadow: var(--shadow-sm); }
.asub-tab:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.asub-group { display: flex; flex-direction: column; gap: var(--space-3); }
.asub-group[hidden] { display: none; }

.contrib-block { display: flex; flex-direction: column; gap: var(--space-3); }
.contrib-hint { font-size: 0.72rem; color: var(--muted); line-height: 1.4; margin: 0; }
.contrib-list { display: flex; flex-direction: column; gap: var(--space-2); }
.contrib-row { display: grid; grid-template-columns: minmax(58px, auto) 1fr minmax(88px, auto); align-items: center; gap: var(--space-2); }
.contrib-id { display: flex; align-items: center; gap: 6px; min-width: 0; }
.contrib-id .asset-avatar { width: 20px; height: 20px; flex: 0 0 auto; }
.contrib-sym { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contrib-bar { height: 8px; border-radius: 999px; background: var(--panel-hover); overflow: hidden; position: relative; }
.contrib-bar > span { display: block; height: 100%; border-radius: 999px; transition: width var(--dur-base) var(--ease-out); }
.contrib-bar > span.pos { background: var(--positive); }
.contrib-bar > span.neg { background: var(--negative); }
.contrib-val { text-align: right; display: flex; flex-direction: column; }
.contrib-val b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.8rem; white-space: nowrap; }
.contrib-val small { font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .asub-tab, .contrib-bar > span { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   PLAN: secciones plegables (todo cerrado al entrar) +
   boton global de plegar/desplegar.
   ═══════════════════════════════════════════════════════ */
.tp-foldall-row { display: flex; justify-content: flex-end; }
.tp-foldall { min-height: var(--control-md); padding: 0 var(--space-4); font-size: 0.76rem; }

.tp-fold { padding: 0; overflow: hidden; }
.tp-fold-sum {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); min-height: 56px;
}
.tp-fold-sum::-webkit-details-marker { display: none; }
.tp-fold-sum:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.tp-fold-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tp-fold-txt strong { font-size: 0.9rem; line-height: 1.25; }
.tp-fold-txt small { font-size: 0.66rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.tp-fold-badge {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
  padding: 2px var(--space-2); border-radius: 999px;
}
.tp-fold-badge.positive { color: var(--positive); background: var(--positive-bg); }
.tp-fold-badge.negative { color: var(--negative); background: var(--negative-bg); }
.tp-fold-chev { color: var(--muted); font-size: 0.8rem; flex: 0 0 auto; transition: transform var(--dur-fast) var(--ease-out); }
.tp-fold[open] .tp-fold-chev { transform: rotate(180deg); }
.tp-fold-body {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--line); margin-top: 0; padding-top: var(--space-3);
}
/* Los bloques 1 y 2 conservan su franja de color a la izquierda */
.tp-fold.tp-block { border-left: 3px solid transparent; }
.tp-fold.tp-block-prog { border-left-color: var(--accent); }
.tp-fold.tp-block-full { border-left-color: var(--accent2, #a988ff); }
.tp-fold .tp-card-id small { font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) { .tp-fold-chev { transition: none; } }

/* Categoría por sector: fila con etiqueta, barra, % y activos del sector. */
.category-row { align-items: center; }
.category-assets {
  grid-column: 1 / -1; font-family: var(--font-mono); font-size: 0.6rem;
  color: var(--muted); padding-left: 18px; margin-top: -2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Selector de tema (claro / oscuro / OLED) ── */
.theme-picker { display: flex; gap: 4px; padding: 3px; background: var(--panel-soft); border-radius: var(--radius-sm); }
.theme-opt {
  flex: 1; min-height: var(--control-md); border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.74rem; font-weight: 600;
  cursor: pointer; padding: 0 6px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
}
.theme-opt.is-active { background: var(--panel-hover); color: var(--accent); box-shadow: var(--shadow-sm); }
.theme-opt:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ── Pestaña principal (Portafolio) destacada en la barra inferior ── */
.tab-btn-primary { position: relative; color: var(--text); }
.tab-btn-primary svg {
  padding: 6px; border-radius: 999px;
  background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--line-accent);
  width: 34px; height: 34px;
}
.tab-btn-primary span { font-weight: 700; }
.tab-btn-primary.is-active svg { background: var(--accent); color: #04121a; box-shadow: var(--glow-accent); }

@media (prefers-reduced-motion: reduce) { .theme-opt { transition: none; } }

/* ── Cuadros plegables de la pestaña Más ── */
.more-fold { padding: 0; overflow: hidden; }
.more-fold-sum {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); min-height: 56px;
}
.more-fold-sum::-webkit-details-marker { display: none; }
.more-fold-sum:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.more-fold-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.more-fold-txt small { font-size: 0.58rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--font-mono); }
.more-fold-txt strong { font-size: 0.95rem; }
.more-fold-chev { color: var(--muted); font-size: 0.8rem; flex: 0 0 auto; transition: transform var(--dur-fast) var(--ease-out); }
.more-fold[open] .more-fold-chev { transform: rotate(180deg); }
.more-fold-body {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--line);
}
@media (prefers-reduced-motion: reduce) { .more-fold-chev { transition: none; } }

/* ── Densidad compacta: valores definitivos ──
   Se aplica siempre (la vista compacta es la norma). Este bloque es la unica
   fuente para la densidad: antes convivia con reglas de menor especificidad
   que quedaban anuladas y el resultado no llegaba a verse compacto. */

/* Plan: cabeceras, cuerpo y contenido de cada seccion */
:root[data-density="compact"] #planContent { gap: 6px; }
:root[data-density="compact"] .tp-fold-sum { min-height: 40px; padding: 4px 10px; gap: 8px; }
:root[data-density="compact"] .tp-fold-txt strong { font-size: 0.78rem; line-height: 1.2; }
:root[data-density="compact"] .tp-fold-txt small { font-size: 0.58rem; line-height: 1.25; margin-top: 1px; }
:root[data-density="compact"] .tp-fold-body { padding: 6px 10px 8px; gap: 6px; padding-top: 6px; }
:root[data-density="compact"] .tp-fold-badge { font-size: 0.72rem; padding: 1px 7px; }
:root[data-density="compact"] .tp-steps { gap: 4px; }
:root[data-density="compact"] .tp-step { padding: 5px 8px; border-radius: 9px; }
:root[data-density="compact"] .tp-step-top { font-size: 0.68rem; }
:root[data-density="compact"] .tp-step-grid { gap: 4px; margin-top: 3px; }
:root[data-density="compact"] .tp-step-grid span { font-size: 0.5rem; }
:root[data-density="compact"] .tp-step-grid b { font-size: 0.68rem; }
:root[data-density="compact"] .tp-config { padding: 5px 8px; gap: 3px; border-radius: 9px; }
:root[data-density="compact"] .tp-config-row,
:root[data-density="compact"] .tp-config-legend { grid-template-columns: 32px 1fr 62px 22px; gap: 5px; }
:root[data-density="compact"] .tp-config-price,
:root[data-density="compact"] .tp-config-pct input { min-height: 30px; padding: 0 6px; }
:root[data-density="compact"] .tp-config-del { width: 22px; height: 22px; }
:root[data-density="compact"] .tp-config-label { font-size: 0.66rem; }
:root[data-density="compact"] .tp-summary,
:root[data-density="compact"] .tp-global-grid { padding: 7px 10px; gap: 4px 10px; border-radius: 10px; }
:root[data-density="compact"] .tp-summary b,
:root[data-density="compact"] .tp-global-grid b { font-size: 0.74rem; }
:root[data-density="compact"] .tp-summary span,
:root[data-density="compact"] .tp-global-grid span { font-size: 0.5rem; }
:root[data-density="compact"] .tp-scenarios { gap: 6px; }
:root[data-density="compact"] .tp-scenario { padding: 7px 10px; gap: 5px; }
:root[data-density="compact"] .tp-line { margin: 0 0 2px; }
:root[data-density="compact"] .tpl-top { height: 15px; }
:root[data-density="compact"] .tp-full-grid { gap: 4px 10px; }
:root[data-density="compact"] .tp-detail-head { margin: 0 0 -4px; }
:root[data-density="compact"] .tpg-row { padding: 4px 0; font-size: 0.64rem; }
:root[data-density="compact"] .tp-quick-row { gap: 7px; }
:root[data-density="compact"] .tp-quick-field input { min-height: 32px; }

/* Insights */
:root[data-density="compact"] .insights-rankings-grid { gap: 7px; }
:root[data-density="compact"] .insights-rankings-grid h3 { font-size: 0.7rem; margin-bottom: 3px; }
:root[data-density="compact"] .insights-rankings-grid .hl-list { gap: 4px; }
:root[data-density="compact"] .hl-item { padding: 5px 8px; gap: 8px; border-radius: 9px; }
:root[data-density="compact"] .hl-item .asset-avatar { width: 22px; height: 22px; }
:root[data-density="compact"] .hl-main strong { font-size: 0.76rem; }
:root[data-density="compact"] .hl-main small { font-size: 0.58rem; }
:root[data-density="compact"] .hl-pct { font-size: 0.74rem; }

/* Resto de la app */
:root[data-density="compact"] .portfolio-mobile-list { gap: 5px; }
:root[data-density="compact"] .market-mobile-list { gap: 4px; }
:root[data-density="compact"] .amc-head { min-height: 44px; padding: 5px 10px; gap: 8px; }
:root[data-density="compact"] .amc-avatar { width: 26px; height: 26px; }
:root[data-density="compact"] .amc-name { font-size: 0.84rem; }
:root[data-density="compact"] .amc-value .money { font-size: 0.84rem; }
:root[data-density="compact"] .amc-subline { padding: 0 10px 6px; font-size: 0.72rem; }
:root[data-density="compact"] .amc-grid { padding: 6px 10px; gap: 5px 10px; }
:root[data-density="compact"] .amc-tps { padding: 0 10px 6px; }
:root[data-density="compact"] .mmi-head { min-height: 44px; padding: 5px 10px; }
:root[data-density="compact"] .mmi-head > .asset-avatar { width: 26px; height: 26px; }
:root[data-density="compact"] .mmi-id strong { font-size: 0.82rem; }
:root[data-density="compact"] .more-fold-sum { min-height: 44px; padding: 6px 12px; }
:root[data-density="compact"] .more-fold-body { padding: 8px 12px 12px; gap: 10px; }
:root[data-density="compact"] .analytics-view { gap: 10px; }
:root[data-density="compact"] .as-clean { gap: 12px; }
@media (max-width: 768px) {
  :root[data-density="compact"] .panel { padding: 12px; }
}


/* ═══════════════════════════════════════════════════════
   DOCK INFERIOR v12 — barra más estrecha y Portafolio
   sobresaliendo con volumen (efecto 3D / profundidad).
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Barra más baja y ceñida: el icono central se sale por arriba. */
  .tab-bar { padding: 3px; border-radius: 22px; overflow: visible; }
  .tab-btn { min-height: 44px; border-radius: 16px; }
  .tab-btn svg { width: 21px; height: 21px; }
  .tab-btn span { font-size: 0.6rem; }

  /* Portafolio: círculo elevado que rompe el borde superior del dock. */
  .tab-btn-primary { overflow: visible; justify-content: flex-end; padding-bottom: 2px; }
  .tab-btn-primary svg {
    width: 46px; height: 46px; padding: 12px;
    margin-top: -26px; margin-bottom: 1px;
    border-radius: 50%;
    color: #04121a;
    background: linear-gradient(155deg, #7dffc9, var(--accent) 45%, #16b47a);
    box-shadow:
      0 8px 18px rgba(0, 0, 0, 0.45),
      0 2px 5px rgba(0, 0, 0, 0.35),
      inset 0 2px 3px rgba(255, 255, 255, 0.55),
      inset 0 -3px 5px rgba(0, 60, 40, 0.35),
      0 0 0 4px var(--bg-2);
    transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  }
  .tab-btn-primary:active svg { transform: translateY(2px) scale(0.96); box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 2px 3px rgba(255,255,255,.4), 0 0 0 4px var(--bg-2); }
  .tab-btn-primary.is-active svg { box-shadow: 0 10px 22px rgba(0,0,0,.5), inset 0 2px 3px rgba(255,255,255,.6), inset 0 -3px 5px rgba(0,60,40,.35), 0 0 0 4px var(--bg-2), var(--glow-accent); }
  .tab-btn-primary.is-active { background: transparent; }
  .tab-btn-primary span { font-size: 0.6rem; font-weight: 700; color: var(--accent); }
}
@media (prefers-reduced-motion: reduce) { .tab-btn-primary svg { transition: none; } }


/* Los plegables no llevan el padding del panel: su relleno vive en el cuerpo.
   (La regla generica .panel del modo compacto lo estaba re-aplicando y cada
   seccion cerrada crecia ~24px de mas.) */
:root[data-density="compact"] .tp-fold,
:root[data-density="compact"] .more-fold { padding: 0; }

/* Subtitulo de cada seccion en una sola linea: evita cabeceras de 2-3 lineas
   y deja todas las filas cerradas a la misma altura. */
:root[data-density="compact"] .tp-fold-txt small,
:root[data-density="compact"] .more-fold-txt small {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
:root[data-density="compact"] .tp-fold-txt { overflow: hidden; }
