/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  min-width: 0;
  animation: rise var(--t-med) var(--ease) both;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.card-head h2 { font-size: 16px; }
.card-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card-pad { padding: var(--sp-5); }

/* Animaciones de entrada SOLO de movimiento: nunca empiezan invisibles. Si el navegador no las reproduce (pestaña en
   segundo plano, ahorro de energía…), el contenido se ve igual en su sitio final. */
@keyframes rise { from { transform: translateY(6px); } to { transform: none; } }
@keyframes fade { from { transform: translateY(3px); } to { transform: none; } }
@keyframes dim { from { background-color: transparent; } }

@media (max-width: 860px) {
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
}

/* ---------- KPI ---------- */
.kpi { display: grid; gap: 4px; padding: var(--sp-4) var(--sp-5); }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 520; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--font-display); font-size: clamp(19px, 1.7vw, 24px); font-weight: 650; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 13px; }
.kpi-hero .kpi-value { font-size: clamp(24px, 2.4vw, 32px); }
@media (max-width: 860px) {
  .kpi { padding: var(--sp-3) var(--sp-4); }
  .kpi-value { font-size: 18px; letter-spacing: -.025em; }
  .kpi-hero { grid-column: 1 / -1; }
  .kpi-hero .kpi-value { font-size: 28px; }
}

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta-pill { padding: 2px 8px; border-radius: 999px; font-size: 13px; }
.delta-pill.up { background: var(--up-soft); }
.delta-pill.down { background: var(--down-soft); }
.delta-pill.flat { background: var(--surface-2); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-weight: 580; font-size: 14px; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(79, 78, 224, .25); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 35%, var(--border)); }
.btn-danger:hover { background: var(--down-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; border-color: transparent; background: transparent; }
.icon-btn.sm:hover { background: var(--surface-2); }

/* ---------- Control segmentado ---------- */
.seg {
  position: relative; display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 11px; border: 1px solid var(--border);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; color: var(--text-2);
  height: 28px; padding: 0 11px; border-radius: 8px; font-size: 13px; font-weight: 580; white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--surface-3); }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 13px; font-weight: 560; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.field .error { font-size: 12px; color: var(--down); }
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--down); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select-sm { height: 34px; font-size: 13.5px; border-radius: 10px; background-position: calc(100% - 17px) 14px, calc(100% - 12px) 14px; }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) {
  .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; margin-bottom: var(--sp-3); }

.scope .select { height: 34px; font-size: 13.5px; border-radius: 10px; max-width: 220px; background-color: var(--surface); background-position: calc(100% - 17px) 14px, calc(100% - 12px) 14px; }

/* ---------- Chips de estado ---------- */
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  padding: 5px 10px; border-radius: 999px; background: var(--surface-2);
}
.status-chip:empty { display: none; }
button.status-chip { border: 0; font-family: inherit; cursor: pointer; transition: background var(--t-fast) var(--ease); }
button.status-chip:hover { background: var(--surface-3); }
.price-rows { display: grid; gap: var(--sp-3); }
.price-row { display: grid; gap: 2px; font-size: 13.5px; }
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-chip.ok .dot { background: var(--accent); }
.status-chip.loading .dot { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 560; white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge-buy { background: var(--accent-soft); color: var(--accent); }
.badge-sell { background: var(--surface-3); color: var(--text); }
.badge-dividend { background: var(--warn-soft); color: var(--warn-ink); }
.badge-split { background: var(--surface-3); color: var(--text-2); }
.split-ratio { flex-wrap: wrap; }
.split-ratio .input { width: 90px; }
/* Buscador de productos al registrar un ETC, ETF o fondo de materias primas (components/forms.js). Lista neutra: sin
   destacar ningún resultado. */
.finder-row { flex-wrap: nowrap; }
.finder-row .input { flex: 1 1 auto; min-width: 0; }
.finder-list { display: grid; gap: 0; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.finder-list:empty { display: none; }
.finder-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); }
.finder-item:first-child { border-top: 0; }
.finder-main { display: grid; min-width: 0; }
.finder-name { overflow-wrap: anywhere; }
.product-finder p { margin: 0; }

/* ---------- Banner ---------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  margin: var(--sp-2) var(--sp-6) 0; padding: 10px 16px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--text); font-size: 14px;
  max-width: calc(1320px - 2 * var(--sp-6));
}
.banner.warn { background: var(--warn-soft); }
@media (min-width: 1384px) { .banner { margin-left: auto; margin-right: auto; width: calc(100% - 2 * var(--sp-6)); } }
@media (max-width: 860px) { .banner { margin: var(--sp-2) var(--sp-4) 0; } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 560; font-size: 12.5px; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table th.num, .table td.num { text-align: right; }
.table th button.sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.table th button.sort:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table .asset-cell { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.asset-avatar { flex: none; display: grid; place-items: center; line-height: 0; }
/* Iconos de activos: relleno suave y borde del color del activo; letras con el color de texto (contraste alto). */
.ai { display: block; overflow: visible; }
.ai-shape { fill: color-mix(in srgb, var(--ai, var(--accent)) 16%, var(--surface)); stroke: var(--ai, var(--accent)); stroke-width: 2; }
.ai-inner { fill: none; stroke: var(--ai, var(--accent)); stroke-width: 1.2; opacity: .7; }
.ai-dashed { stroke-dasharray: 4 3; }
.ai-text { fill: var(--text); font-family: var(--font); font-weight: 700; letter-spacing: .02em; }
.asset-name { font-weight: 600; line-height: 1.25; }
.asset-meta { font-size: 12.5px; color: var(--text-3); }
.cell-stack { display: grid; gap: 1px; justify-items: end; }

/* Lista en tarjetas para móvil */
.list-cards { display: none; }
@media (max-width: 760px) {
  .table-responsive { display: none; }
  .list-cards { display: grid; }
}
.list-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 14px var(--sp-4); border-bottom: 1px solid var(--border); background: none; border-left: 0; border-right: 0; border-top: 0;
  text-align: left; width: 100%; color: inherit;
}
.list-card:last-child { border-bottom: 0; }
.list-card .main-line { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-card .sub-line { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; height: 380px; touch-action: pan-y; }
.chart-lg { height: 440px; }
.chart-md { height: 320px; }
.chart-sm { height: 260px; }
.chart-map { height: 460px; }
@media (max-width: 860px) {
  .chart-lg { height: 340px; }
  .chart { height: 300px; }
  .chart-map { height: 320px; }
}
.chart-fade { animation: fade var(--t-med) var(--ease) both; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend button {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font-size: 12.5px; font-weight: 560;
  transition: opacity var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.legend button:hover { background: var(--surface-2); }
.legend button[aria-pressed="false"] { opacity: .45; }
.legend button[aria-pressed="false"] .swatch { background: transparent !important; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; border: 2px solid currentColor; }
.swatch.line { height: 3px; border-radius: 2px; border: 0; width: 14px; }
.swatch.dash { height: 0; width: 14px; border: 0; border-top: 2px dashed currentColor; border-radius: 0; background: none !important; }

/* Colores de serie por clase (sin estilos en línea, compatible con la CSP) */
.c-s0 { color: var(--s0); } .c-s1 { color: var(--s1); } .c-s2 { color: var(--s2); } .c-s3 { color: var(--s3); }
.c-s4 { color: var(--s4); } .c-s5 { color: var(--s5); } .c-s6 { color: var(--s6); } .c-s7 { color: var(--s7); }
.c-muted { color: var(--text-3); } .c-up { color: var(--up); } .c-down { color: var(--down); } .c-accent { color: var(--accent); }
.bg-s0 { background: var(--s0); } .bg-s1 { background: var(--s1); } .bg-s2 { background: var(--s2); } .bg-s3 { background: var(--s3); }
.bg-s4 { background: var(--s4); } .bg-s5 { background: var(--s5); } .bg-s6 { background: var(--s6); } .bg-s7 { background: var(--s7); }
.bg-muted { background: var(--text-3); } .bg-accent { background: var(--accent); } .bg-up { background: var(--up); } .bg-down { background: var(--down); }

/* Tooltip común de todos los gráficos */
.tt {
  min-width: 190px; max-width: 300px; padding: 10px 12px;
  font-family: var(--font); font-size: 12.5px; line-height: 1.4; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tt-title { font-weight: 650; margin-bottom: 6px; color: var(--text); }
.tt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 1.5px 0; }
.tt-row .k { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-row .v { font-weight: 600; white-space: nowrap; }
.tt-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tt-sep { height: 1px; background: var(--border); margin: 6px 0; }
.tt-note { color: var(--text-3); font-size: 11.5px; margin-top: 4px; }
.tt-op { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; color: var(--text-2); }

.lwc-tooltip {
  position: absolute; z-index: 20; pointer-events: none; top: 0; left: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.lwc-tooltip.show { opacity: 1; }

.chart-head-value { font-family: var(--font-display); font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
@media (max-width: 860px) { .chart-head-value { font-size: 24px; } }

/* ---------- Métricas ---------- */
.metric-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.metric {
  position: relative; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2);
  display: grid; gap: 4px; animation: rise var(--t-med) var(--ease) both;
}
.metric-name { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 560; }
.metric-value { font-family: var(--font-display); font-size: 21px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.metric-cmp { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.info-btn {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-3); padding: 0;
}
/* Zona táctil de al menos 24 × 24 px sin cambiar el tamaño del icono. */
.info-btn { position: relative; }
.info-btn::before { content: ''; position: absolute; inset: -4px; border-radius: 50%; }
.badge-estimate .info-btn::before { inset: -5px; }
.info-btn:hover, .info-btn:focus-visible { color: var(--accent); }
.info-btn svg { width: 15px; height: 15px; }

.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker button {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 560;
  transition: all var(--t-fast) var(--ease);
}
.picker button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Popover (explicaciones) ---------- */
.popover {
  position: fixed; z-index: 90; max-width: 300px; padding: 12px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); font-size: 13px; line-height: 1.5;
  animation: fade var(--t-fast) var(--ease) both;
}
.popover strong { display: block; margin-bottom: 4px; font-size: 13.5px; }
.popover-link { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 600; }
.popover .formula { margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: var(--backdrop);
  display: grid; place-items: center; padding: var(--sp-4);
  animation: dim var(--t-fast) var(--ease);
}
.modal {
  width: min(680px, 100%); max-height: min(90vh, 900px); overflow: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  animation: pop var(--t-med) var(--ease) both;
}
.modal-sm { width: min(440px, 100%); }
@keyframes pop { from { transform: translateY(10px) scale(.98); } to { transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-5) 0; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: var(--sp-5); display: grid; gap: var(--sp-4); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@media (max-width: 600px) {
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); animation-name: sheet; }
  @keyframes sheet { from { transform: translateY(40px); } to { transform: none; } }
}

/* ---------- Toast ---------- */
.toast-root { position: fixed; z-index: 95; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
@media (max-width: 860px) { .toast-root { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }
.toast {
  padding: 12px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 14px; animation: pop var(--t-med) var(--ease) both;
}
.toast.error { background: var(--down); color: #fff; }
:root[data-theme="dark"] .toast.error { color: var(--bg); } /* el rojo claro del modo oscuro necesita texto oscuro */

/* ---------- Estados vacíos y carga ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-4); }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h2 { font-size: 20px; }
.empty p { color: var(--text-2); max-width: 460px; }
.empty-sm { padding: var(--sp-6) var(--sp-4); }

.hero-welcome { padding: var(--sp-7) var(--sp-5); }
.hero-welcome h2 { font-size: 28px; letter-spacing: -.02em; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-md); }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 14px; margin: 8px 0; }
.sk-chart { height: 360px; }

/* ---------- Barras de peso ---------- */
.weight-bar { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.weight-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); transform-origin: left; animation: grow var(--t-med) var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

.breakdown { display: grid; gap: 10px; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 13.5px; }
.breakdown-row .weight-bar { grid-column: 1 / -1; }

/* ---------- Detalle de país ---------- */
.country-detail { display: grid; gap: var(--sp-3); align-content: start; }
.country-detail .big { font-family: var(--font-display); font-size: 26px; font-weight: 650; letter-spacing: -.02em; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 560; }

.divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

.prose { max-width: 760px; display: grid; gap: var(--sp-3); color: var(--text-2); }
.prose h2 { color: var(--text); margin-top: var(--sp-4); }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.prose strong { color: var(--text); }

.key-mask { font-family: var(--mono); letter-spacing: .05em; }

.filters { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); align-items: end; }
@media (max-width: 1080px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters .full { grid-column: 1 / -1; } }

/* Filas de leyenda pulsables (reparto, países) */
.legend-row {
  width: 100%; border: 0; background: transparent; color: inherit; text-align: left; font: inherit;
  padding: 6px 8px; margin: 0 -8px; border-radius: var(--r-sm); width: calc(100% + 16px);
  transition: background-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.legend-row:hover { background: var(--surface-2); }
.legend-row[aria-pressed="false"] { opacity: .45; }
.legend-row .swatch { border: 0; }
a.list-card:hover, a.breakdown-row:hover { text-decoration: none; background: var(--surface-2); }
a.breakdown-row { color: inherit; padding: 6px 8px; margin: 0 -8px; border-radius: var(--r-sm); }
.list-card .weight-bar { width: 90px; }
.alloc-legend { align-content: center; }
.breakdown-row .row { flex-wrap: nowrap; min-width: 0; }


/* ======================================================================
   Seguimiento, avisos, estimaciones y piezas compartidas
   ====================================================================== */
.row-tight { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stack-sm { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr); }
.big { font-family: var(--font-display); font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.warn-text { color: var(--warn-ink); }
.kpis-3 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Estimaciones, aproximaciones y avisos */
.badge-estimate { background: var(--warn-soft); color: var(--warn-ink); }
.badge-estimate .info-btn { width: 15px; height: 15px; color: inherit; }
.badge-estimate .info-btn svg { width: 13px; height: 13px; }
.fiscal-note { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); font-weight: 500; }
.banner-inline { padding: 10px 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); font-size: 14px; }
.banner-inline.warn { background: var(--warn-soft); }
.banner-soft { background: var(--surface-2); border: 1px solid var(--border); }
.disclaimer { max-width: 860px; }

/* Precio en vivo */
.live-tag { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; }
.flash { animation: flash 900ms var(--ease); border-radius: 4px; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

/* Pestañas dentro de una pantalla */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px; color: var(--text-2); font-weight: 580; font-size: 14px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* «Más» en la barra inferior del móvil */
.tab-more { border: 0; background: none; font: inherit; }
@media (max-width: 860px) {
  .tabbar .tab-more { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 560; }
  .tabbar .tab-more[aria-current="page"] { color: var(--accent); }
  .tabbar .tab-more svg { width: 21px; height: 21px; }
}
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.more-nav { display: grid; gap: var(--sp-3); }
.more-grid-featured { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.more-grid-featured .more-item { background: var(--surface-2); padding: 14px 12px; font-weight: 620; }
.more-grid-featured .more-item:hover { background: var(--surface-3); }
.more-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md); color: var(--text); font-weight: 560; }
.more-item:hover { background: var(--surface-2); text-decoration: none; }
.more-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; flex: none;
  background: var(--accent-soft); color: var(--accent);
}
.more-icon svg { width: 19px; height: 19px; }

/* Buscador de activos */
.search-box { position: relative; display: grid; gap: 6px; }
.search-input { position: relative; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search-input .input { padding-left: 38px; }
.search-results {
  position: absolute; z-index: 40; top: 44px; left: 0; right: 0; max-height: 360px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 4px; animation: fade var(--t-fast) var(--ease) both;
}
.search-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; color: inherit; text-align: left; font: inherit;
}
.search-row:hover, .search-row:focus-visible { background: var(--surface-2); outline: none; }
.search-main { display: grid; min-width: 0; }
.search-main .asset-name, .search-main .asset-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-loading { padding: 8px 12px; }

/* Lista de seguimiento */
.watch-row {
  display: grid; grid-template-columns: auto minmax(0, 1.4fr) minmax(90px, 1fr) auto auto; gap: var(--sp-4); align-items: center;
  padding: 14px var(--sp-5); border-bottom: 1px solid var(--border);
}
.watch-row:last-child { border-bottom: 0; }
.watch-name { min-width: 0; }
.watch-name .asset-name, .watch-name .asset-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { height: 38px; width: 100%; }
.watch-changes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .watch-row { grid-template-columns: auto minmax(0, 1fr); padding: 12px var(--sp-4); gap: var(--sp-2) var(--sp-3); }
  .watch-row > .cell-stack { grid-column: 1 / -1; grid-row: 2; justify-items: start; }
  .watch-row .watch-changes { justify-content: flex-start; }
  .watch-row .spark { grid-column: 1 / -1; grid-row: 3; }
  .watch-row .watch-actions { grid-column: 1 / -1; grid-row: 4; justify-content: flex-end; }
}

/* Objetivos, rebalanceo y escenarios */
.goal-progress { display: grid; gap: 8px; margin-bottom: var(--sp-4); }
.weight-bar-lg { height: 10px; border-radius: 5px; }
.weight-bar-lg > span { border-radius: 5px; }
.goal-facts { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: var(--sp-4); }
.target-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: var(--sp-4); }
.scenario-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: var(--sp-4); }
.scenario-opt { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.scenario-opt .input { width: 110px; }
.table-compact td, .table-compact th { padding: 8px 12px; }
.plan-row { padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-row:last-child { border-bottom: 0; }

/* Selector de métricas por grupos */
.picker-group { display: grid; gap: 6px; }
.picker-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.compare-table td:first-child { min-width: 180px; }

/* ---------- Aviso de clave que falta ---------- */
.key-notice { display: inline-flex; align-items: flex-start; gap: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.key-notice svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--accent); }
.key-notice a { font-weight: 600; }
.key-notice-block { display: flex; padding: 10px 12px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); font-size: 13px; }

/* ---------- Gráfico de precio (Análisis) ---------- */
.price-foot { margin-top: var(--sp-2); }
.price-legend { gap: var(--sp-4); }
.price-legend .swatch { display: inline-block; margin-right: 6px; vertical-align: middle; }
.seg.is-disabled { opacity: .45; pointer-events: none; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.metric-cmp .key-notice { font-size: 12px; }
.chart-foot { margin-top: var(--sp-3); }

/* Un selector con opciones largas no debe ensanchar la página en el móvil. */
.select { min-width: 0; max-width: 100%; }
@media (max-width: 860px) {
  /* Los selectores de la cabecera de una tarjeta pasan a otra línea si no caben. */
  .card-head > .row { flex-wrap: wrap; max-width: 100%; min-width: 0; }
}

/* ---------- Resumen por bloques ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); align-items: start; }
.dash-full { grid-column: 1 / -1; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; justify-self: start; }
.link-btn:hover { text-decoration: underline; }
.icon-btn-sm { width: 30px; height: 30px; font-size: 18px; line-height: 1; }
.explain-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.explain-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.last-visit h2 { font-size: 16px; }
.last-visit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-top: var(--sp-3); }
@media (max-width: 860px) { .last-visit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.table-periods td, .table-periods th { padding-top: 9px; padding-bottom: 9px; }
.table-periods tr.muted td { color: var(--text-3); }
/* Cascada del patrimonio */
.wf { display: grid; gap: 10px; }
.wf-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 110px; gap: 12px; align-items: center; font-size: 13.5px; }
.wf-label { color: var(--text-2); }
.wf-value { text-align: right; font-weight: 600; }
.wf-track { position: relative; height: 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.wf-bar { position: absolute; top: 0; bottom: 0; border-radius: 4px; transition: left var(--t-med) var(--ease), width var(--t-med) var(--ease); }
.wf-base { background: var(--text-3); opacity: .55; }
.wf-flow { background: var(--accent); }
.wf-up { background: var(--up); }
.wf-down { background: var(--down); }
.wf-extra { display: grid; gap: 6px; margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: 13.5px; }
.wf-extra > div { display: flex; justify-content: space-between; gap: 12px; }
.wf-total { padding-top: 6px; }
@media (max-width: 520px) { .wf-row { grid-template-columns: 110px minmax(0, 1fr) 92px; font-size: 12.5px; } }
.movers-col + .movers-col { margin-top: var(--sp-4); }
.list-card-tight { padding: 8px 0; }
@media (prefers-reduced-motion: reduce) { .wf-bar { transition: none; } }
@media (max-width: 860px) { .hide-mobile { display: none !important; } }

/* ---------- Importador CSV ---------- */
.modal-lg { width: min(980px, 100%); }
.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
.map-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 2px 10px; align-items: center; font-size: 13px; }
.map-row .map-sample { grid-column: 2; min-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csv-preview { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: 12.5px; }
.row-error td { background: var(--warn-soft); }
@media (max-width: 700px) { .map-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Personalizar el Resumen ---------- */
.dash-head { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; margin-bottom: calc(-1 * var(--sp-3)); }
.dash-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dash-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); transition: opacity var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.dash-item.is-hidden { opacity: .55; }
.dash-item.dragging { box-shadow: var(--shadow-md); }
.dash-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.drag-handle { cursor: grab; color: var(--text-3); letter-spacing: -2px; touch-action: none; user-select: none; padding: 4px; }
.dash-check { margin: 0; }
/* Contribución */
.contrib-list { display: grid; gap: 8px; }
.contrib-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 30% 84px; gap: 10px; align-items: center; color: inherit; font-size: 13px; }
.contrib-row:hover { text-decoration: none; }
.contrib-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contrib-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 4px; }
.contrib-bar { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.contrib-row .num { text-align: right; }

/* ---------- Botón flotante (móvil) ---------- */
.fab { display: none; }
@media (max-width: 860px) {
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 40;
    width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lg); transition: transform var(--t-fast) var(--ease); }
  .fab svg { width: 24px; height: 24px; }
  .fab:active { transform: scale(.94); }
  .fab.hidden { display: none; }
  :root[data-fab] #btn-add { display: none; } /* con el botón flotante, sin un segundo «+» arriba */
}
/* ---------- Teclas (atajos y buscador) ---------- */
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; font-family: var(--mono); font-size: 12px; text-align: center; background: var(--surface-2); }
/* ---------- Densidad compacta ---------- */
:root[data-density="compact"] .card { padding: var(--sp-4); }
:root[data-density="compact"] .stack, :root[data-density="compact"] .dash-grid { gap: var(--sp-3); }
:root[data-density="compact"] .table td, :root[data-density="compact"] .table th { padding-top: 6px; padding-bottom: 6px; }
:root[data-density="compact"] .list-card { padding-top: 9px; padding-bottom: 9px; }
:root[data-density="compact"] .kpi-value { font-size: clamp(17px, 1.5vw, 21px); }
:root[data-density="compact"] .view { padding-top: var(--sp-3); }
.toast-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toast-btn { border: 0; background: none; color: var(--accent-2); font-weight: 700; padding: 4px 6px; border-radius: 6px; }
.th-actions, .row-actions { width: 1%; white-space: nowrap; }
.row-actions .btn { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.table tr:hover .row-actions .btn, .table tr:focus-within .row-actions .btn { opacity: 1; }
@media (hover: none) { .row-actions .btn { opacity: 1; } }
/* ---------- Primer uso ---------- */
.onb-hint { max-width: 620px; margin: var(--sp-3) auto 0; text-align: center; }
.onb { list-style: none; margin: var(--sp-5) auto 0; padding: 0; display: grid; gap: var(--sp-4); max-width: 620px; }
.onb-step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; align-items: start; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.onb-step p { margin: 4px 0 10px; }
.onb-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-family: var(--font-serif, var(--font)); }
.onb-demo { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: var(--sp-5); flex-wrap: wrap; }

/* ---------- Tesis ---------- */
.thesis { margin: 0; display: grid; gap: 4px 0; }
.thesis dt { font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
.thesis dd { margin: 0; white-space: pre-wrap; line-height: 1.55; }
.thesis-sm dd { font-size: 13px; color: var(--text-2); }
.thesis-versions { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.thesis-versions > li { padding: 10px 12px; border-left: 2px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.thesis-list { display: grid; gap: var(--sp-3); }
.thesis-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: inherit; }
.thesis-item:hover { text-decoration: none; border-color: var(--border-strong); }
/* ---------- Temas ---------- */
.tags-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 550; }
.tag-x { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.tag-x:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tag-input { flex: 1 1 220px; min-width: 0; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-filter button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.tag-filter button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.theme-row { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr) 70px; gap: 12px; align-items: center; font-size: 13.5px; padding: 6px 0; }
.commodity-row { display: grid; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.commodity-row:last-child { border-bottom: 0; padding-bottom: 0; }
.theme-row .assets { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); margin-top: -4px; }

/* ---------- Importar ---------- */
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; border: 1.5px dashed var(--border-strong, var(--border)); border-radius: var(--r-lg, var(--r-md)); background: var(--surface-2); cursor: pointer; transition: border-color .18s ease, background .18s ease; }
.dropzone svg { width: 26px; height: 26px; color: var(--accent); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.import-help summary { cursor: pointer; font-size: 14px; font-weight: 550; }
.import-help p { margin: 6px 0 4px; }
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.type-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-muted td { color: var(--text-2); }
@media (max-width: 700px) { .type-grid { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .dropzone { transition: none; } }
.portfolio-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: var(--sp-2, 8px); align-items: center; }
@media (max-width: 700px) { .portfolio-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .portfolio-row > :first-child { grid-column: 1 / -1; } }
.seg-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }

/* ---------- Fiscalidad ---------- */
.tax-disclaimer { margin: 0; max-width: none; display: block; line-height: 1.5; }
.tax-steps td:first-child { width: 100%; }
.tax-total td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.tax-table details.lots summary { cursor: pointer; color: var(--text-2); margin-top: 2px; }
.tax-table details.lots ul { margin: 4px 0 0; padding-left: 16px; }
.tax-block { display: grid; gap: 8px; align-content: start; box-shadow: none; background: var(--surface-2); }
.tax-sources summary { cursor: pointer; font-weight: 600; }
#print-root { display: none; }
/* Fortaleza orientativa de la contraseña de la copia cifrada (components/backup.js): neutro, sin verde ni rojo. */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--border); transition: background-color .2s; }
.pw-meter span.on { background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .pw-meter span { transition: none; } }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; color: #000; background: #fff; font: 10.5pt/1.4 -apple-system, "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
  #print-root h1 { font-size: 17pt; margin: 0 0 6pt; }
  #print-root h2 { font-size: 12.5pt; margin: 14pt 0 4pt; }
  #print-root table { width: 100%; border-collapse: collapse; }
  #print-root th, #print-root td { border-bottom: .5pt solid #bbb; padding: 3pt 4pt; text-align: left; vertical-align: top; }
  #print-root .num { text-align: right; white-space: nowrap; }
  #print-root .p-warn { border: .75pt solid #888; padding: 6pt 8pt; }
  #print-root .p-foot { margin-top: 14pt; color: #444; font-size: 9pt; }
  #print-root tr { break-inside: avoid; }
  /* Informe mensual y anual de la cartera (components/report.js). */
  @page { size: A4; margin: 14mm 13mm 16mm; }
  #print-root.p-report { font-size: 9.5pt; line-height: 1.45; color: #1d2230; }
  #print-root.p-report .p-head { border-bottom: 1.5pt solid #4f4ee0; padding-bottom: 8pt; margin-bottom: 10pt; }
  #print-root.p-report .p-brand { margin-bottom: 4pt; }
  #print-root.p-report .p-brand svg { display: block; height: 18pt; width: auto; }
  #print-root.p-report h1 { font-family: ui-serif, "New York", "Iowan Old Style", Georgia, serif; font-size: 20pt; font-weight: 600; margin: 2pt 0 3pt; }
  #print-root.p-report h2 { font-size: 11.5pt; margin: 0 0 6pt; color: #1d2230; }
  #print-root.p-report h3 { font-size: 9.5pt; margin: 0 0 4pt; color: #4b5563; }
  #print-root.p-report .p-meta, #print-root.p-report .p-note { color: #4b5563; font-size: 8.5pt; }
  #print-root.p-report .p-note { margin: 4pt 0 0; }
  #print-root.p-report .p-warn { border: .75pt solid #b7791f; color: #7a4b00; padding: 4pt 8pt; margin: 0 0 8pt; font-size: 8.5pt; }
  #print-root.p-report .p-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6pt; margin-bottom: 12pt; }
  #print-root.p-report .p-kpi { border: .75pt solid #e5e7eb; border-radius: 6pt; padding: 7pt 9pt; break-inside: avoid; }
  #print-root.p-report .p-kpi-label { font-size: 8pt; color: #4b5563; }
  #print-root.p-report .p-kpi-value { font-size: 14pt; font-weight: 650; margin-top: 1pt; }
  #print-root.p-report .p-kpi-sub { font-size: 7.5pt; color: #6b7280; margin-top: 1pt; }
  #print-root.p-report .p-section { margin: 0 0 12pt; }
  #print-root.p-report .p-avoid { break-inside: avoid; }
  #print-root.p-report .p-chart { width: 100%; height: auto; display: block; }
  #print-root.p-report .p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12pt; }
  #print-root.p-report .p-mt { margin-top: 8pt; }
  #print-root.p-report table { font-size: 8.8pt; }
  #print-root.p-report th { color: #4b5563; font-weight: 600; border-bottom-color: #9ca3af; }
  #print-root.p-report .p-left td.num, #print-root.p-report .p-left th { text-align: left; }
  #print-root.p-report .p-left td:last-child, #print-root.p-report .p-left th:last-child { text-align: right; }
  #print-root.p-report .p-total td { font-weight: 650; border-top: .75pt solid #9ca3af; }
  #print-root.p-report .p-up { color: #17803d; }
  #print-root.p-report .p-down { color: #c0392b; }
  #print-root.p-report .p-months { display: grid; grid-template-columns: repeat(12, 1fr); text-align: center; font-size: 7.8pt; margin-top: 3pt; }
  #print-root.p-report .p-months span { display: block; color: #6b7280; }
  #print-root.p-report .p-donut { display: flex; align-items: center; gap: 10pt; margin-bottom: 6pt; }
  #print-root.p-report .p-keys { display: grid; gap: 2pt; font-size: 8pt; }
  #print-root.p-report .p-foot { margin-top: 14pt; border-top: .75pt solid #e5e7eb; padding-top: 6pt; color: #4b5563; font-size: 8pt; break-inside: avoid; }
  #print-root.p-report .p-foot p { margin: 0 0 3pt; }
}
/* Frase con controles en línea (Análisis › Divisas › simulación). */
.sim-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-line .select { width: auto; min-width: 88px; }
.sim-line .input { width: 92px; }
/* Los selectores pequeños de cabeceras y barras no se estiran a todo el ancho. */
.card-head .select-sm, .tax-head .select-sm { width: auto; min-width: 88px; }

/* ---------- Exposición › Rayos X ---------- */
.xray-funds { display: grid; }
.xray-fund { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.xray-fund:first-child { border-top: 0; padding-top: 0; }
.xray-fund-name { flex-wrap: nowrap; min-width: 0; gap: 10px; }
.xray-fund-name > div { min-width: 0; overflow-wrap: anywhere; }
.xray-fund-actions { grid-column: 1 / -1; gap: 6px; justify-content: flex-end; }
@media (min-width: 900px) {
  .xray-fund { grid-template-columns: minmax(0, 1fr) 64px auto; }
  .xray-fund-actions { grid-column: auto; }
}
.xray-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px; gap: 2px 12px; align-items: center; font-size: 13.5px; padding: 4px 0; }
.xray-row .weight-bar { grid-column: 1 / -1; }
.xray-row > .num, .xray-head > span:not(:first-child) { text-align: right; }
.xray-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xray-head { padding-bottom: 6px; }
.xray-company { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 14px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--border); }
.xray-company:first-child { border-top: 0; }
.xray-company-name { min-width: 0; overflow-wrap: anywhere; }
.xray-via { grid-column: 1 / -1; overflow-wrap: anywhere; }
.xray-pair { border-top: 1px solid var(--border); padding: 8px 0; }
.xray-pair summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; cursor: pointer; font-size: 13.5px; }
.xray-pair summary .faint { grid-column: 1 / -1; }
.xray-shared { display: grid; gap: 4px; margin-top: 8px; }
.xray-shared-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 72px; gap: 12px; }
.xray-shared-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xray-shared-row > span:not(:first-child) { text-align: right; }
.input-sm { height: 34px; font-size: 13.5px; padding: 0 10px; border-radius: 10px; }
.holdings-edit { min-width: 700px; }
.holdings-edit td { padding: 4px 6px; }
.holdings-edit td:nth-child(5) .input { width: 84px; text-align: right; }
@media (max-width: 520px) {
  .xray-row { grid-template-columns: minmax(0, 1fr) 76px 76px; gap: 2px 8px; }
  .xray-company { grid-template-columns: minmax(0, 1fr) auto; }
  .xray-company > .num.small { grid-column: 2; }
}

/* ---------- Precios que actualiza el usuario ---------- */
.row-actions .btn.btn-price { opacity: 1; }
.price-note { display: inline; }
.price-notice { display: block; color: var(--text-2); }
.list-card-group { border-bottom: 1px solid var(--border); }
.list-card-group:last-child { border-bottom: 0; }
.list-card-group .list-card { border-bottom: 0; padding-bottom: 6px; }
.list-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 0 var(--sp-4) 12px calc(var(--sp-4) + 46px); font-size: 12.5px; color: var(--text-3); }
.manual-prices { display: grid; }
.manual-price { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.manual-price:first-child { border-top: 0; padding-top: 0; }
.manual-price .small { overflow-wrap: anywhere; }
.manual-price-name { flex-wrap: nowrap; min-width: 0; } .manual-price-name > div { min-width: 0; }

/* ---------- Tu plan: calculadoras, entradas y fuentes ---------- */
.calc-layout { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.calc-in, .calc-out { min-width: 0; }
.calc-actions { flex-wrap: wrap; }
.calc-tax { display: block; line-height: 1.5; }
.calc-scen { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.calc-scen legend { padding: 0 6px; font-size: 13px; font-weight: 560; color: var(--text-2); }
.calc-h { font-size: 15px; font-weight: 650; margin: 0; }
.calc-sources { border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.calc-sources summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.calc-sources ul { margin-top: var(--sp-2); }
.calc-grid, .plan-entries { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.plan-entries { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.calc-card, .plan-entry {
  display: grid; gap: 6px; align-content: start; padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.calc-card:hover, .plan-entry:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); text-decoration: none; }
.calc-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); }
.calc-icon svg { width: 18px; height: 18px; }
.plan-entry { background: var(--surface-2); }
@media (prefers-reduced-motion: reduce) { .calc-card, .plan-entry { transition: none; } .calc-card:hover, .plan-entry:hover { transform: none; } }
@media (max-width: 1100px) { .calc-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .calc-scen .form-grid-3 { grid-template-columns: minmax(0, 1fr); } }
.calc-path { display: grid; gap: var(--sp-3); align-content: start; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); min-width: 0; }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.event-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.form-row { flex-wrap: nowrap; }
.form-row .input { min-width: 0; }
.table tr.row-current td { background: var(--accent-soft); }
.nw-line { font-size: 13.5px; color: var(--text-2); }
@media (max-width: 600px) { .calc-mode .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; } .calc-mode .seg button { white-space: normal; } }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13.5px; font-weight: 560; justify-self: start; }
.back-link svg { width: 16px; height: 16px; flex: none; }

/* ---------- Calendario (Al día) ---------- */
/* Un color por categoría, de la paleta de series (sin verdes ni rojos, que se reservan para subidas y bajadas). */
.cal-c0 { --c: var(--s0); } .cal-c1 { --c: var(--s1); } .cal-c2 { --c: var(--s2); } .cal-c3 { --c: var(--s3); }
.cal-c4 { --c: var(--s4); } .cal-c5 { --c: var(--s5); } .cal-c6 { --c: var(--s6); } .cal-c7 { --c: var(--s7); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.cal-head { display: grid; gap: var(--sp-4); }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.cal-title-row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.cal-title { font-family: var(--font-serif); font-weight: 500; font-size: 22px; letter-spacing: -.01em; }
.cal-title::first-letter, .cal-side-head h3::first-letter, .cal-list-date::first-letter { text-transform: uppercase; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-next svg { transform: scaleX(-1); }
.cal-actions { gap: var(--sp-2); }
.cal-c8 { --c: var(--cal-8); } .cal-c9 { --c: var(--cal-9); }
.cal-filterset { border: 0; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.cal-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; }
.cal-check { min-height: 32px; padding: 4px 6px; border-radius: var(--r-sm, 8px); font-size: 13.5px; }
.cal-check:hover { background: var(--surface-2); }
.cal-check input { accent-color: var(--c); flex: none; }
.cal-check-actions { gap: var(--sp-2); }
.cal-filter-btn { display: none; }
.cal-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-5); align-items: start; }
.cal-layout-list { grid-template-columns: minmax(0, 1fr) 260px; }
.cal-side { position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 24px); overflow: auto; }
.cal-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--sp-3); }
.cal-side-head h3 { font-size: 15px; }
.cal-card { padding: var(--sp-4); }

.cal-month { display: grid; gap: 4px; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow-cell { padding: 2px 6px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.cal-day {
  min-width: 0; min-height: 98px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cal-day:hover { background: var(--surface-2); }
.cal-day.is-other { background: transparent; border-color: transparent; color: var(--text-3); }
.cal-day.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-day.is-today .cal-num, .cal-week-head.is-today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-pills { display: grid; gap: 2px; min-width: 0; }
.cal-pill {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 1px 6px;
  border-left: 3px solid var(--c); border-radius: 5px; background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--text); font-size: 11.5px; line-height: 1.4;
}
.cal-more { padding-left: 6px; font-size: 11px; color: var(--text-3); }
.cal-dots { display: none; gap: 3px; justify-content: center; }
.cal-dots .cal-dot { width: 6px; height: 6px; }

.cal-ev-list { display: grid; gap: var(--sp-2); }
.cal-ev {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px;
  border-left: 3px solid var(--c); border-radius: var(--r-md); background: var(--surface-2);
}
.cal-ev-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.cal-ev-icon svg { width: 16px; height: 16px; }
.cal-ev-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-ev-title { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
a.cal-ev-title:hover { text-decoration: underline; }
.cal-ev-sub { margin-top: 2px; }
.cal-ev-side { display: grid; justify-items: end; gap: 6px; text-align: right; }
.cal-ev-amount { font-weight: 600; white-space: nowrap; }
.cal-ev-actions { gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.cal-ev-compact { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 6px 8px; }
.cal-ev-compact .cal-ev-icon { display: none; }
.cal-ev-compact .cal-ev-title { font-size: 12.5px; }
.cal-ev-compact .cal-ev-side { justify-items: start; text-align: left; }

.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-week-col { display: grid; align-content: start; gap: 6px; min-width: 0; }
.cal-week-head {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.cal-week-head.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-week-dow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.cal-week-empty { padding: 4px 8px; }

.cal-list { display: grid; gap: var(--sp-5); }
.cal-list-date { margin-bottom: var(--sp-2); font-size: 14px; }
.cal-list-date.is-today { color: var(--accent-text); }
.cal-summary li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.cal-summary li:last-child { border-bottom: 0; }
.cal-missing li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.cal-missing li:last-child { border-bottom: 0; }
.cal-how summary { cursor: pointer; font-weight: 600; }
.cal-how[open] summary { margin-bottom: var(--sp-3); }
.cal-gap { display: flex; align-items: flex-start; gap: 6px; }
.cal-gap svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* Al pasar de mes deslizando el dedo: solo movimiento (el contenido se ve aunque la animación no se reproduzca). */
.cal-slide-left { animation: cal-in-left var(--t-med) var(--ease); }
.cal-slide-right { animation: cal-in-right var(--t-med) var(--ease); }
@keyframes cal-in-left { from { transform: translateX(16px); } to { transform: none; } }
@keyframes cal-in-right { from { transform: translateX(-16px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .cal-slide-left, .cal-slide-right { animation: none; } }

@media (max-width: 1180px) { .cal-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 1080px) {
  .cal-layout, .cal-layout-list { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; max-height: none; }
  .cal-day { min-height: 86px; }
}
@media (max-width: 860px) {
  .cal-side { display: none; } /* en el móvil, el detalle del día se abre en una hoja desde abajo */
  .cal-filters { display: none; } /* en el móvil, las casillas se abren con el botón «Filtros» */
  .cal-filter-btn { display: inline-flex; }
  .modal .cal-checks { grid-template-columns: minmax(0, 1fr); }
  .modal .cal-check { min-height: 40px; font-size: 15px; }
  .cal-card { padding: var(--sp-3); }
  .cal-title { font-size: 19px; }
  .cal-month, .cal-row { gap: 2px; }
  .cal-dow-cell { padding: 2px 0 4px; text-align: center; font-size: 10.5px; }
  .cal-day { min-height: 52px; align-items: center; gap: 4px; padding: 4px 2px; }
  .cal-pills { display: none; }
  .cal-dots { display: flex; }
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .cal-week-col { grid-template-columns: 74px minmax(0, 1fr); align-items: start; }
  .cal-ev { grid-template-columns: 26px minmax(0, 1fr); }
  .cal-ev-icon { width: 26px; height: 26px; }
  .cal-ev-side { grid-column: 2; justify-items: start; text-align: left; }
  .cal-ev-actions { justify-content: flex-start; flex-wrap: wrap; }
}
/* Bloque «Próximos 7 días» del Resumen */
.agenda { gap: 0; }
.agenda-row { display: grid; grid-template-columns: 9px 84px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.agenda-row:last-child { border-bottom: 0; }
.agenda-date { font-size: 13px; color: var(--text-2); }
.agenda-title { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.agenda-title a { color: var(--text); }
@media (max-width: 520px) { .agenda-row { grid-template-columns: 9px 64px minmax(0, 1fr); } .agenda-row > .num { grid-column: 3; } }
.agenda-row.agenda-data { grid-template-columns: minmax(0, 1fr) auto; }

/* ---------- Datos oficiales (Al día) ---------- */
.datos-intro { margin-top: calc(var(--sp-2) * -1); }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--sp-4); }
.ind-card { display: grid; align-content: start; gap: var(--sp-2); text-align: left; font: inherit; color: var(--text); cursor: pointer; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
button.ind-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.ind-card.is-error { cursor: default; }
.ind-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ind-name { font-size: 14px; font-weight: 600; color: var(--text-2); }
.ind-body { display: grid; gap: 4px; }
.ind-value { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.ind-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ind-source { margin-top: auto; }
.ind-table td, .ind-table th { padding: 4px 6px; }
.ind-chart { height: 280px; }
.ind-cite { display: grid; gap: 4px; padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.delta-neutral { color: var(--text-2); }
.boe-group { font-size: 14px; margin-bottom: var(--sp-2); }
.boe-list { gap: 0; }
.boe-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.boe-item:last-child { border-bottom: 0; }
.boe-title { color: var(--text); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.boe-title:hover { color: var(--accent-text); }
.sources-list { gap: var(--sp-3); }
.sources-list li { display: grid; gap: 2px; }
@media (max-width: 520px) { .ind-grid { grid-template-columns: minmax(0, 1fr); } .ind-chart { height: 230px; } }
.cal-actions .select { width: auto; min-width: 110px; }
.ind-card.is-loading { cursor: default; }
