* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* LOGIN SCREEN */
.login-screen {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  background-image:
    radial-gradient(ellipse at top, rgba(212, 255, 58, 0.06), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(212, 255, 58, 0.03), transparent 50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: 'Inter', -apple-system, sans-serif;
  color: #f5f5f5;
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: #131313;
  border: 1px solid #262626;
  border-radius: 24px;
  padding: 36px 28px 28px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #d4ff3a, #9bbf28);
  color: #0a0a0a;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 600;
}

.login-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #888;
}

.login-error {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #f87171;
  margin-bottom: 12px;
  min-height: 16px;
  text-align: center;
}

.login-footer {
  font-size: 10px;
  color: #555;
  text-align: center;
  margin-top: 18px;
  letter-spacing: 0.05em;
}

.login-version {
  font-size: 10px;
  color: #444;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.15em;
}

/* SYNC INDICATOR */
.sync-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  right: 16px;
  z-index: 50;
  /* Es puramente informativo y se solapa con el botón de menú (arriba-derecha).
     Sin esto, un indicador atascado (p.ej. estado de error que no se auto-oculta)
     intercepta los toques y el botón de menú "deja de funcionar". */
  pointer-events: none;
  background: rgba(20, 20, 20, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid #262626;
  border-radius: 999px;
  padding: 4px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #888;
  letter-spacing: 0.05em;
}

.sync-indicator.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

.sync-indicator.ok {
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
}

:root {
  --bg: #0a0a0a;
  --bg-elev: #131313;
  --bg-card: #1a1a1a;
  --border: #262626;
  --border-soft: #1f1f1f;
  --text: #f5f5f5;
  --text-dim: #888;
  --text-muted: #555;
  --accent: #d4ff3a;
  --accent-dim: #9bbf28;
  --green: #4ade80;
  --red: #f87171;
  --gold: #fbbf24;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: calc(80px + var(--safe-bottom));
  background-image:
    radial-gradient(ellipse at top, rgba(212, 255, 58, 0.04), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(212, 255, 58, 0.02), transparent 50%);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.display {
  font-family: 'Fraunces', serif;
}

/* HEADER */
header {
  padding: 24px 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

header .label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

header h1 {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
}

header h1 em {
  font-style: italic;
  color: var(--accent);
}

.date-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
}

/* TOTAL */
.total-card {
  margin: 8px 20px 24px;
  padding: 28px 24px;
  background: linear-gradient(140deg, #1a1a1a 0%, #0f0f0f 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

.total-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(212, 255, 58, 0.08), transparent 70%);
  border-radius: 50%;
}

.total-card .label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.total-value {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 44px;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 14px;
}

.total-value .currency {
  font-size: 20px;
  color: var(--text-dim);
  margin-right: 6px;
  vertical-align: top;
  margin-top: 8px;
  display: inline-block;
}

.total-meta {
  display: flex;
  gap: 24px;
  align-items: center;
}

.total-meta .pnl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
}

.total-meta .pnl.up {
  color: var(--green);
}

.total-meta .pnl.down {
  color: var(--red);
}

.total-meta .invested {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

/* TABS */
.tabs {
  display: flex;
  gap: 0;
  margin: 0 20px 20px;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1 0 auto;
  min-width: 80px;
  padding: 12px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  white-space: nowrap;
}

.tab.active {
  color: var(--text);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* VIEWS */
.view {
  display: none;
  padding: 0 20px;
}

.view.active {
  display: block;
}

/* ASSETS LIST */
.section-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 24px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-label .count {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

/* REFRESH BUTTON */
.refresh-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.refresh-btn:active {
  transform: scale(0.96);
}

.refresh-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.refresh-btn svg {
  transition: transform 0.4s;
  flex-shrink: 0;
}

.refresh-btn.loading svg {
  animation: spin 0.8s linear infinite;
}

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

.refresh-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.refresh-status.loading {
  color: var(--text-dim);
}

.refresh-status.ok {
  color: var(--green);
}

.refresh-status.warn {
  color: var(--gold);
}

.refresh-status.idle {
  color: var(--text-muted);
}

/* SOURCE BADGE in price updater */
.price-source {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.price-source.auto {
  background: rgba(74, 222, 128, 0.1);
  color: var(--green);
}

.price-source.manual {
  background: rgba(212, 255, 58, 0.1);
  color: var(--accent-dim);
}

.price-source.error {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
}

/* FILTER PANEL */
.section-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

#filterBtn {
  padding: 6px 10px;
}

#filterBtn.has-filters {
  border-color: rgba(212, 255, 58, 0.3);
  color: var(--accent);
}

.filter-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--accent);
  margin-left: 2px;
}

.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  animation: panelSlide 0.2s ease;
}

@keyframes panelSlide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-section {
  margin-bottom: 14px;
}

.filter-section:last-of-type {
  margin-bottom: 0;
}

.filter-section-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.filter-selects {
  display: flex;
  gap: 8px;
}

.filter-select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:active {
  transform: scale(0.96);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
}

.filter-reset {
  width: 100%;
  margin-top: 12px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-reset:active {
  transform: scale(0.98);
}

.filter-reset:hover {
  color: var(--text-dim);
}

.empty-filter {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 14px;
  font-size: 12px;
}

.asset {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
  transition: border-color 0.2s, transform 0.1s;
}

.asset:active {
  transform: scale(0.99);
  border-color: var(--border);
}

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

.asset-id {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0;
}

.icon-eth {
  background: linear-gradient(135deg, #627eea, #3c5fdb);
  color: #fff;
}

.icon-bnb {
  background: linear-gradient(135deg, #f3ba2f, #c89a25);
  color: #1a1a1a;
}

.icon-xaut {
  background: linear-gradient(135deg, #b45309, #78350f);
  color: #fff;
}

.icon-amundi {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  font-size: 9px;
}

.asset-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.asset-platform {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.asset-value {
  text-align: right;
}

.asset-value .v {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 15px;
}

.asset-value .qty {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.asset-value .pnl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  margin-top: 2px;
}

.pnl.up {
  color: var(--green);
}

.pnl.down {
  color: var(--red);
}

.pnl.neutral {
  color: var(--text-muted);
}

.asset-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
}

.realized-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: inline-block;
}

.realized-badge.up {
  background: rgba(74, 222, 128, 0.08);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.realized-badge.down {
  background: rgba(248, 113, 113, 0.08);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.stat .lbl {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
}

/* DISTRIBUTION */
.distribution {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.donut {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}

.legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-name {
  flex: 1;
  color: var(--text-dim);
}

.legend-pct {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  font-weight: 500;
}

/* FEES BARS */
.fee-row {
  margin-bottom: 14px;
}

.fee-row:last-child {
  margin-bottom: 0;
}

.fee-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.fee-row-id {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fee-row-id .asset-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 9px;
}

.fee-row-name {
  font-size: 13px;
  font-weight: 500;
}

.fee-row-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

.fee-row-bar {
  height: 6px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.fee-row-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.fee-row-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
}

/* CHART */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 400;
}

.chart-title em {
  color: var(--accent);
  font-style: italic;
}

/* INPUT FORM */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* OP TOGGLE */
.op-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
}

.op-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.op-btn .op-icon {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
}

.op-btn[data-op="buy"].active {
  background: rgba(74, 222, 128, 0.12);
  color: var(--green);
}

.op-btn[data-op="sell"].active {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

/* CURRENCY TOGGLE */
.amount-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.amount-row input {
  flex: 1;
}

.currency-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}

.cur-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 0 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
}

.cur-btn.active {
  background: var(--accent);
  color: #0a0a0a;
}

.rate-hint {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(212, 255, 58, 0.06);
  border: 1px solid rgba(212, 255, 58, 0.15);
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
}

.rate-hint.error {
  background: rgba(248, 113, 113, 0.06);
  border-color: rgba(248, 113, 113, 0.2);
  color: var(--red);
}

.rate-hint .rate-value {
  color: var(--accent);
  font-weight: 500;
}

.pnl-preview {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
}

.pnl-preview .pnl-row {
  display: flex;
  justify-content: space-between;
}

.pnl-preview .pnl-row.total {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 6px;
  font-weight: 600;
}

.pnl-preview .pnl-row.total.up {
  color: var(--green);
}

.pnl-preview .pnl-row.total.down {
  color: var(--red);
}

.pnl-preview .pnl-label {
  color: var(--text-muted);
}

.btn {
  width: 100%;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

/* Estado desactivado (p.ej. "Eliminar" hasta escribir la frase correcta):
   apariencia claramente inactiva e inmune al tap. Funciona en ambos temas. */
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  display: flex;
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

/* TRANSACTIONS LIST */
.tx {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  margin-bottom: 8px;
}

.tx-info .tx-asset {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.tx-info .tx-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.tx-pnl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  margin-top: 4px;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
}

.tx-pnl.up {
  background: rgba(74, 222, 128, 0.1);
  color: var(--green);
}

.tx-pnl.down {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
}

.tx.tx-sell {
  border-left: 3px solid var(--red);
}

.tx-amount {
  text-align: right;
}

.tx-amount .a {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
}

.tx-amount .u {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tx-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  margin-left: 8px;
  cursor: pointer;
  font-size: 18px;
}

/* EMPTY */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty .display {
  font-size: 22px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.empty p {
  font-size: 13px;
  line-height: 1.5;
}

/* BOTTOM NAV */
nav.bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 10, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-soft);
  padding: 10px 20px calc(10px + var(--safe-bottom));
  display: flex;
  justify-content: space-around;
  z-index: 100;
}

nav.bottom button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 10px;
  transition: color 0.2s;
}

nav.bottom button.active {
  color: var(--accent);
}

nav.bottom button svg {
  width: 22px;
  height: 22px;
}

/* CHART SVG */
.line-chart {
  width: 100%;
  height: 180px;
}

/* MICRO */
.divider-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin: 24px 0 16px;
  position: relative;
}

.divider-text::before,
.divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border-soft);
}

.divider-text::before {
  left: 0;
}

.divider-text::after {
  right: 0;
}

.price-update-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 8px;
  gap: 10px;
}

.price-update-row .name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.price-update-row input {
  width: 110px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  text-align: right;
}

/* INSTALL HINT */
.install-hint {
  margin: 0 20px 16px;
  padding: 14px 16px;
  background: rgba(212, 255, 58, 0.06);
  border: 1px solid rgba(212, 255, 58, 0.2);
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.install-hint strong {
  color: var(--accent);
  font-weight: 600;
}

.install-hint .close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view.active>* {
  animation: fadeUp 0.3s ease both;
}

.view.active>*:nth-child(2) {
  animation-delay: 0.05s;
}

.view.active>*:nth-child(3) {
  animation-delay: 0.1s;
}

.view.active>*:nth-child(4) {
  animation-delay: 0.15s;
}

/* HEADER RIGHT + HAMBURGER */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-btn {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  padding: 0;
}

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

.menu-btn .menu-bar {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: background 0.2s;
}

.menu-btn:hover .menu-bar {
  background: var(--accent);
}

/* SIDE MENU */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 200;
}

.menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  /* Cerrado: fuera de pantalla Y sin capturar toques (defensa por si durante la
     transición de cierre el panel aún cubre parte de la derecha). */
  pointer-events: none;
}

.side-menu.open {
  pointer-events: auto;
  transform: translateX(0);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
}

.side-menu-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.side-menu-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.side-menu-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 26px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.side-menu-close:hover {
  background: var(--bg-card);
  color: var(--text);
}

.side-menu-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.side-menu-body .menu-item:not(:last-child) {
  border-bottom: 1px solid var(--border-soft);
}

.menu-item-text {
  text-align: left;
}

.menu-item-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.menu-item-hint {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.menu-item-action {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.menu-item-action:active {
  opacity: 0.65;
}

.menu-item-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.menu-item-action:active .menu-item-icon {
  color: var(--accent);
  border-color: rgba(212, 255, 58, 0.3);
}

html.theme-light .menu-item-action:active .menu-item-icon {
  border-color: rgba(107, 143, 16, 0.35);
}

.menu-item-action.loading .menu-item-icon svg {
  animation: spin 0.8s linear infinite;
}

.menu-item-action.loading .menu-item-icon {
  color: var(--accent);
}

.menu-item-danger .menu-item-label {
  color: var(--red);
}

.menu-item-danger:active .menu-item-icon {
  color: var(--red);
  border-color: rgba(255, 80, 80, 0.35);
}

.side-menu-footer {
  padding: 14px 22px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-align: center;
}

/* SWITCH */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background: #0a0a0a;
}

/* LIGHT THEME */
html.theme-light {
  --bg: #f5f5f4;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --border: #e5e5e3;
  --border-soft: #ececea;
  --text: #1a1a1a;
  --text-dim: #555;
  --text-muted: #8a8a87;
  --accent: #6b8f10;
  --accent-dim: #4d6b07;
  --green: #16a34a;
  --red: #dc2626;
  --gold: #b45309;
}

html.theme-light body {
  background-image:
    radial-gradient(ellipse at top, rgba(107, 143, 16, 0.06), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(107, 143, 16, 0.03), transparent 50%);
}

html.theme-light .total-card {
  background: linear-gradient(140deg, #ffffff 0%, #f0f0ee 100%);
}

html.theme-light .total-card::before {
  background: radial-gradient(circle, rgba(107, 143, 16, 0.1), transparent 70%);
}

html.theme-light nav.bottom {
  background: rgba(255, 255, 255, 0.85);
}

html.theme-light .sync-indicator {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-dim);
}

html.theme-light .chip.active,
html.theme-light .cur-btn.active,
html.theme-light .btn {
  color: #ffffff;
}

/* El botón "Cancelar" de los modales es .btn-secondary (fondo transparente sobre
   caja clara): su texto debe ser oscuro, no blanco. Se acota a .pw-modal-box
   para NO afectar al botón de passkey del login, que vive sobre fondo oscuro. */
html.theme-light .pw-modal-box .btn-secondary {
  color: var(--text);
}

html.theme-light .switch input:checked + .switch-track .switch-thumb {
  background: #ffffff;
}

html.theme-light .install-hint {
  background: rgba(107, 143, 16, 0.08);
  border-color: rgba(107, 143, 16, 0.25);
}

html.theme-light .rate-hint {
  background: rgba(107, 143, 16, 0.08);
  border-color: rgba(107, 143, 16, 0.2);
}

/* TAPPABLE CHART CARD */
.chart-card-tappable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.chart-card-tappable:hover {
  border-color: var(--border);
}

.chart-card-tappable:active {
  transform: scale(0.995);
}

.chart-expand-hint {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.chart-card-tappable:hover .chart-expand-hint {
  color: var(--accent);
  background: rgba(212, 255, 58, 0.08);
}

html.theme-light .chart-card-tappable:hover .chart-expand-hint {
  background: rgba(107, 143, 16, 0.1);
}

/* CHART MODAL */
.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.chart-modal.open {
  opacity: 1;
  pointer-events: auto;
}

/* Red de seguridad: con el modal cerrado, ningún hijo del SVG debe capturar
   punteros. El <rect class="chart-touch-zone"> usa pointer-events="all", que
   por sí solo overridea el pointer-events:none del modal y, al estar éste a
   pantalla completa con opacity:0, bloquearía los clics de la pantalla
   principal (tabs, filtro). Forzamos none también en los descendientes. */
.chart-modal:not(.open) #chartModalSvg,
.chart-modal:not(.open) #chartModalSvg * {
  pointer-events: none !important;
}

.chart-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.chart-modal-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.chart-modal-title em {
  color: var(--accent);
  font-style: italic;
}

.chart-modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.chart-modal-close:hover {
  background: var(--border-soft);
  color: var(--text);
}

.chart-modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  overflow-x: auto;
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.toolbar-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chart-modal-toolbar .filter-chips {
  flex-wrap: nowrap;
}

.chart-modal-toolbar .chip {
  font-size: 11.5px;
  padding: 6px 11px;
}

.asset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.chart-modal-body {
  flex: 1;
  min-height: 0;
  padding: 8px 8px 0;
  display: flex;
}

.chart-modal-body svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}

.chart-modal-body svg .chart-touch-zone {
  cursor: crosshair;
}

.chart-modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 10px 20px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chart-modal-footer strong {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

.chart-modal-footer strong.up { color: var(--green); }
.chart-modal-footer strong.down { color: var(--red); }

/* CHART TOOLTIP */
.chart-tooltip {
  position: fixed;
  z-index: 600;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  min-width: 140px;
  display: none;
}

.chart-tooltip .tip-title {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border-soft);
  padding-bottom: 4px;
}

.chart-tooltip .tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11.5px;
}

.chart-tooltip .tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-tooltip .tip-label {
  color: var(--text-dim);
  flex: 1;
}

.chart-tooltip .tip-value {
  color: var(--text);
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

/* ============ MODAL GESTIÓN DE ACTIVOS ============ */
.assets-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px calc(28px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.assets-section-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.asset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 8px;
}

.asset-row-info {
  flex: 1;
  min-width: 0;
}

.asset-row-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.asset-row-key {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

.asset-row-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-row-del {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--red);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.asset-row-del:active {
  background: var(--red);
  color: #fff;
}

.asset-row-lock {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px 8px;
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
}

.na-status {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 16px;
  margin: 4px 0 10px;
}

.na-status.error {
  color: var(--red);
}

/* ============ MODAL CONFIRMAR CONTRASEÑA ============ */
.pw-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.pw-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.pw-modal-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev, var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pw-modal-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.pw-modal-title em {
  color: var(--accent);
  font-style: italic;
}

.pw-modal-message {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 16px;
}

.pw-modal-box input[type="password"],
.pw-modal-box input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.05em;
}

.pw-modal-box input[type="password"]:focus,
.pw-modal-box input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Frase exacta a escribir para confirmar (estilo "teclea el nombre del repo"). */
.pw-modal-code {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 8px;
  margin: 2px 0;
  user-select: all;
  -webkit-user-select: all;
}

.pw-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.pw-modal-actions .btn {
  flex: 1;
  margin: 0;
}

/* LANDSCAPE — toolbar más compacta */
@media (orientation: landscape) and (max-height: 500px) {
  .chart-modal-header {
    padding: 8px 16px;
  }

  .chart-modal-title {
    font-size: 18px;
  }

  .chart-modal-toolbar {
    padding: 8px 16px 10px;
    gap: 10px 14px;
  }

  .toolbar-label {
    display: none;
  }

  .chart-modal-footer {
    padding: 6px 16px;
    font-size: 10.5px;
  }
}
