/* ============================================================
   Dashboard CSS — Alertas Legalmente Fácil (v6)
   Sin librerías ni CDN. Fuente Inter autoalojada (OFL, fonts/).
   Tema claro/oscuro por variables. Contraste AA en ambos temas.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('fonts/InterVariable-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c1d22;
  --muted: #5b5f68;
  --border: #e1e3e8;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-2: #2563eb;
  --accent-soft: rgba(139, 92, 246, .12);
  --on-accent: #ffffff;
  --link: #5b21b6;
  --link-hover: #4c1d95;
  --up: #17803a;
  --up-bg: rgba(23, 128, 58, .1);
  --down: #c0262d;
  --down-bg: rgba(192, 38, 45, .1);
  --flat: #5b5f68;
  --flat-bg: rgba(91, 95, 104, .1);
  --ring-seen: #b9bcc4;
  --overlay: rgba(10, 10, 20, .55);
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.06);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.18);
  --radius: 14px;
  --radius-sm: 10px;
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 45%, #2563eb 100%);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --accent-2-soft: rgba(37, 99, 235, .1);
  --skel: #e6e7ec;
  --skel-hi: #f3f4f7;
  --sidebar-w: 248px;
  --card-pad: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-2: #23233a;
  --text: #f1f1f5;
  --muted: #a9a9bf;
  --border: #2e2e48;
  --accent-soft: rgba(139, 92, 246, .2);
  --link: #c4b5fd;
  --link-hover: #ddd6fe;
  --up: #4ade80;
  --up-bg: rgba(74, 222, 128, .12);
  --down: #f87171;
  --down-bg: rgba(248, 113, 113, .12);
  --flat: #a9a9bf;
  --flat-bg: rgba(169, 169, 191, .12);
  --ring-seen: #4a4a66;
  --overlay: rgba(0, 0, 0, .65);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --accent-2-soft: rgba(96, 165, 250, .16);
  --skel: #26263e;
  --skel-hi: #31314d;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-2: #23233a;
    --text: #f1f1f5;
    --muted: #a9a9bf;
    --border: #2e2e48;
    --accent-soft: rgba(139, 92, 246, .2);
    --link: #c4b5fd;
    --link-hover: #ddd6fe;
    --up: #4ade80;
    --up-bg: rgba(74, 222, 128, .12);
    --down: #f87171;
    --down-bg: rgba(248, 113, 113, .12);
    --flat: #a9a9bf;
    --flat-bg: rgba(169, 169, 191, .12);
    --ring-seen: #4a4a66;
    --overlay: rgba(0, 0, 0, .65);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --accent-2-soft: rgba(96, 165, 250, .16);
    --skel: #26263e;
    --skel-hi: #31314d;
    color-scheme: dark;
  }
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-feature-settings: 'cv11', 'calt';
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
ul { list-style: none; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--accent-strong); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  z-index: 60;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.sidebar-logo:hover { color: var(--text); }
.sidebar-logo-img { width: 36px; height: 36px; border-radius: 10px; }
.sidebar-title { font-weight: 700; font-size: 15px; line-height: 1.25; }
.sidebar-nav { flex: 1; }
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; text-align: left;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer { display: flex; flex-direction: column; gap: 14px; }
.back-link { font-size: 13px; }
.sidebar-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 55; }

.main { flex: 1; min-width: 0; max-width: 1200px; margin: 0 auto; padding: 28px 32px 40px; outline: none; }
.content-header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.greeting { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
.date-subtitle { color: var(--muted); font-size: 14px; }
.date-subtitle span::first-letter { text-transform: uppercase; }
.menu-toggle {
  display: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.menu-toggle-bar { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--text); }

/* ---------------- Tema: toggle pastilla ---------------- */
.theme-toggle {
  position: relative; width: 72px; height: 34px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 9px;
}
.theme-toggle-icon { width: 16px; height: 16px; position: relative; z-index: 1; }
.theme-toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--gradient); box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.theme-toggle[aria-checked="true"] .theme-toggle-thumb { transform: translateX(38px); }
.theme-toggle[aria-checked="false"] .theme-toggle-sun,
.theme-toggle[aria-checked="true"] .theme-toggle-moon { opacity: 0; }

/* ---------------- Tarjetas y secciones ---------------- */
.card, .featured-card, .counter-card, .empty-state-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.view-section > * + * { margin-top: 24px; }
.featured-grid { display: grid; grid-template-columns: 45fr 55fr; gap: 20px; align-items: stretch; }
.featured-card { display: flex; flex-direction: column; gap: 14px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title, .section-title { font-size: 17px; font-weight: 700; }
.view-title { font-size: 22px; font-weight: 750; }
.card-badge, .watchlist-badge {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text);
}
.card-disclaimer, .empty-hint { color: var(--muted); font-size: 13px; }
.counters-explanation { color: var(--muted); font-size: 13px; margin-top: 4px; }
.counters-explanation summary { cursor: pointer; font-weight: 600; color: var(--link); width: fit-content; }
.counters-explanation p { margin-top: 6px; max-width: 70ch; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.door-slot:empty, .door-row:empty { display: none; }
.door-slot { display: flex; }
.door-row { display: flex; flex-wrap: wrap; gap: 10px; }
.loading { color: var(--muted); padding: 8px 0; }
.empty-state-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state { font-weight: 600; }

/* Radar */
.radar-list { display: flex; flex-direction: column; gap: 6px; }
.radar-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); }
.radar-item:hover { background: var(--surface-2); }
.radar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.radar-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.radar-headline { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.radar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.radar-extra { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.radar-why { color: var(--muted); font-size: 12px; }
.radar-why strong { font-weight: 600; }
.radar-concept-link {
  font-size: 12px; font-weight: 600; color: var(--link); padding: 2px 0;
  text-decoration: underline; text-underline-offset: 2px; text-align: left;
}
.radar-item.is-linked, .concept-rel.is-linked { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

/* Concepto */
.concept-card { transition: box-shadow .3s ease, border-color .3s ease; }
.concept-card.concept-flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.concept-title { font-size: 22px; font-weight: 750; line-height: 1.25; }
.concept-text { color: var(--text); }
.concept-content { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.concept-why { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.concept-more summary { cursor: pointer; font-weight: 600; color: var(--link); }
.concept-more p { margin-top: 6px; }
.concept-aviso { font-size: 13px; font-weight: 600; color: var(--muted); }
.concept-related { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.concept-related-title { font-size: 14px; font-weight: 700; }
.concept-related-sub { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 4px; }
.concept-rel-list { display: flex; flex-direction: column; gap: 4px; }
.concept-rel { border-radius: var(--radius-sm); }
.concept-row { width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 8px; text-align: left; border-radius: var(--radius-sm); }
.concept-row:hover { background: var(--surface-2); }
.concept-row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.concept-row-line { color: var(--muted); font-size: 13px; }
.concept-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.concept-actions:not(:has(button:not([hidden]))) { display: none; }
.capas-no-disponible { font-style: italic; }

/* Contadores */
.counters-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 12px 0; }
.counter-card { display: flex; flex-direction: column; gap: 2px; }
.counter-value { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; }
.counter-card.up .counter-value { color: var(--up); }
.counter-card.down .counter-value { color: var(--down); }
.counter-label { color: var(--muted); font-size: 13px; }

/* ---------------- Nombres ---------------- */
.asset-name { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; max-width: 100%; overflow: hidden; }
.asset-name-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.asset-ticker { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; font-weight: 500; }
.type-emoji, .type-icon { flex-shrink: 0; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.type-emoji .icon, .type-icon .icon { width: 18px; height: 18px; }

/* ---------------- Variaciones ---------------- */
.pct {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pct.up { color: var(--up); background: var(--up-bg); }
.pct.down { color: var(--down); background: var(--down-bg); }
.pct.flat { color: var(--flat); background: var(--flat-bg); }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn-primary { background: var(--accent-strong); color: var(--on-accent); }
.btn-primary:hover { background: var(--link); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-ghost { color: var(--link); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-list { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-list:hover { border-color: var(--accent); }
.btn-list.in-list { background: var(--accent-soft); border-color: var(--accent); }
.btn-list.is-blocked { opacity: .6; cursor: not-allowed; }
.door-btn { white-space: normal; text-align: left; }
.link-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; text-align: left; color: var(--text); }
.link-btn:hover .asset-name-text { color: var(--link); text-decoration: underline; }

/* ---------------- Tablas ---------------- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.card.table-wrapper { padding: 0; }
.assets-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.assets-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.assets-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.assets-table tr:last-child td { border-bottom: 0; }
.assets-table tbody tr:hover { background: var(--surface-2); }
.assets-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-name { max-width: 280px; }
.cell-type { color: var(--muted); white-space: nowrap; font-size: 13px; }
.cell-action { text-align: right; }

/* ---------------- Buscador y chips ---------------- */
.asset-search-input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.asset-search-input::placeholder { color: var(--muted); }
.asset-search-input:focus-visible { border-color: var(--accent); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filter-chip {
  min-height: 34px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.filter-chip:hover { border-color: var(--accent); }
.filter-chip.active { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }

/* Listas de activos (catálogo y modal) */
.asset-list { display: flex; flex-direction: column; gap: 4px; }
.asset-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.asset-row:hover { background: var(--surface-2); }
.asset-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.asset-row-text { display: flex; flex-direction: column; min-width: 0; }
.asset-row-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-row-price { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.asset-picker-section { margin-top: 28px; }

/* Mi lista: tarjetas */
.chosen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.chosen-card { display: flex; flex-direction: column; gap: 12px; }
.chosen-top { display: flex; align-items: center; gap: 12px; }
.chosen-text { flex: 1; min-width: 0; }
.chosen-text h4 { font-size: 15px; }
.chosen-meta { color: var(--muted); font-size: 13px; }
.chosen-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Guardados */
.saved-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.saved-tab-btn { padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); }
.saved-tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.saved-tab-panel { margin-top: 16px; }
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-item { display: flex; align-items: center; gap: 12px; }
.saved-item-content { flex: 1; min-width: 0; }
.saved-item-title { font-weight: 700; }
.saved-item-text { margin-top: 6px; }
.saved-item .link-btn { flex: 1; }

.footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------- Avatares con anillo ---------------- */
.story-avatar {
  --size: 48px;
  width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; padding: 3px;
  background: var(--border);
}
.story-avatar-sm { --size: 36px; padding: 2px; }
.story-avatar-md { --size: 48px; }
.story-avatar-lg { --size: 64px; }
.story-avatar.ring-new { background: var(--gradient); }
.story-avatar.ring-seen { background: var(--ring-seen); }
.story-avatar.ring-none { background: transparent; padding: 0; }
.story-avatar-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--size) * .42); line-height: 1; color: var(--link);
}
.story-avatar-inner .icon { width: 50%; height: 50%; }
.story-avatar.ring-none .story-avatar-inner { background: var(--surface-2); border-color: transparent; }
button.story-avatar:hover { transform: scale(1.04); }
button.story-avatar { transition: transform .15s ease; }

/* Bandeja de historias */
.story-tray { display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.story-tray li { flex-shrink: 0; }
.story-tray-item { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; }
.story-tray-item .story-avatar { --size: 68px; }
.story-tray-name { font-size: 12px; max-width: 76px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.story-tray-item:hover .story-avatar { transform: scale(1.04); }

/* ---------------- Modales ---------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal-content, .door-modal-content {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); color: var(--text); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 24px; animation: modal-in .2s ease;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%;
  font-size: 22px; line-height: 1; color: var(--muted); z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close .icon { width: 20px; height: 20px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-title { font-size: 20px; font-weight: 750; padding-right: 40px; min-width: 0; }
.modal-title .asset-name { display: flex; }
.add-asset-modal-header { margin-bottom: 14px; }
.add-asset-counter { color: var(--muted); font-size: 14px; margin-top: 2px; }
.limit-banner {
  padding: 10px 14px; border-radius: 12px; margin-bottom: 10px; font-weight: 600; font-size: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent);
}
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; padding-right: 40px; }
.sheet-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.sheet-meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.sheet-section { padding: 16px 0; border-top: 1px solid var(--border); }
.sheet-section h4 { font-size: 15px; margin-bottom: 10px; }
.sheet-section .muted { margin-bottom: 8px; }
.news-link { font-weight: 600; display: inline-block; margin-bottom: 4px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.modal-content .door-row { margin-top: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.metric { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Barras de 4 capas */
.layers { display: flex; flex-direction: column; gap: 10px; }
.layer-row { display: grid; grid-template-columns: 96px 1fr 80px; align-items: center; gap: 10px; font-size: 13px; }
.layer-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.layer-axis { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: .5; }
.layer-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.layer-fill.up { left: 50%; background: var(--up); }
.layer-fill.down { right: 50%; background: var(--down); }
.layer-fill.flat { left: 50%; background: var(--flat); }
.layers.animate .layer-fill { transform-origin: left center; animation: grow .6s ease both; }
.layers.animate .layer-fill.down { transform-origin: right center; }
.layer-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.layer-value.up { color: var(--up); }
.layer-value.down { color: var(--down); }
.layer-value.flat { color: var(--flat); }

/* ---------------- Puerta de interés ---------------- */
.door-modal-content { max-width: 520px; padding: 0; overflow: hidden; display: grid; }
.door-mockup {
  grid-area: 1 / 1; padding: 28px; display: flex; flex-direction: column; gap: 14px;
  filter: blur(6px); opacity: .7; pointer-events: none; user-select: none;
}
.mock-bar { height: 14px; border-radius: 999px; background: var(--accent-soft); }
.mock-w40 { width: 40%; } .mock-w60 { width: 60%; } .mock-w80 { width: 80%; }
.mock-row { display: flex; align-items: center; gap: 12px; }
.mock-circle { width: 44px; height: 44px; border-radius: 50%; background: var(--gradient); opacity: .6; }
.mock-block { flex: 1; height: 44px; border-radius: 12px; background: var(--surface-2); }
.mock-bars { display: flex; align-items: flex-end; gap: 10px; height: 90px; }
.mock-bars span { flex: 1; border-radius: 8px 8px 0 0; background: var(--accent); opacity: .45; }
.mock-bars span:nth-child(1) { height: 40%; } .mock-bars span:nth-child(2) { height: 75%; }
.mock-bars span:nth-child(3) { height: 55%; } .mock-bars span:nth-child(4) { height: 90%; }
.mock-bars span:nth-child(5) { height: 65%; }
.door-card {
  grid-area: 1 / 1; align-self: center; position: relative;
  margin: 24px; padding: 24px; border-radius: 18px;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 10px;
}
.door-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--link); display: inline-flex; align-items: center; justify-content: center; }
.door-icon .icon { width: 26px; height: 26px; }
.door-title { font-size: 20px; font-weight: 750; padding-right: 36px; }
.door-desc { color: var(--text); }
.door-note { color: var(--muted); font-size: 13px; }
.door-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* ---------------- Visor de historias 9:16 ---------------- */
.story-viewer { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.story-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 12, .88); }
.story-frame {
  position: relative; height: min(92vh, 860px); aspect-ratio: 9 / 16; max-width: 100vw;
  border-radius: 20px; overflow: hidden; color: #fff;
  background: #1a1a2e; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; touch-action: pan-x;
}
.story-progress { display: flex; gap: 4px; padding: 10px 12px 0; position: relative; z-index: 3; }
.story-seg { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
.story-seg-fill { display: block; height: 100%; width: 0; background: #fff; }
.story-seg-fill.done { width: 100%; }
.story-seg-fill.current { animation: progress linear forwards; }
.story-frame.paused .story-seg-fill.current { animation-play-state: paused; }
.story-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: relative; z-index: 3; }
.story-header .story-avatar { background: rgba(255,255,255,.35); }
.story-header .story-avatar-inner { background: #1a1a2e; border-color: #1a1a2e; }
.story-header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.story-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-ticker { font-size: 12px; color: rgba(255,255,255,.75); }
.story-btn { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-size: 18px; line-height: 1; }
.story-btn:hover { background: rgba(255,255,255,.15); }
.story-btn:focus-visible, .story-tap:focus-visible, .btn-story:focus-visible { outline-color: #fff; }
.story-stage {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 22px;
  position: absolute; inset: 0; padding-top: 96px; padding-bottom: 126px;
}
.story-stage.tone-up { background: linear-gradient(160deg, #0f3d2a 0%, #14532d 45%, #1a1a2e 100%); }
.story-stage.tone-down { background: linear-gradient(160deg, #4a1220 0%, #7f1d1d 45%, #1a1a2e 100%); }
.story-stage.tone-flat { background: linear-gradient(160deg, #2e1065 0%, #3730a3 50%, #1a1a2e 100%); }
.story-stage.story-capas, .story-stage.story-resumen { background: linear-gradient(160deg, #2e1065 0%, #1e3a8a 60%, #1a1a2e 100%); }
.story-content { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; position: relative; z-index: 2; }
.story-emoji { width: 64px; height: 64px; border-radius: 18px; background: rgba(255,255,255,.14); display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.story-emoji .icon { width: 34px; height: 34px; }
.story-header .story-avatar-inner { color: #fff; }
.story-btn .icon { width: 20px; height: 20px; }
.story-title { font-size: 26px; font-weight: 800; line-height: 1.15; }
.story-headline { font-size: 21px; font-weight: 700; line-height: 1.3; }
.story-source, .story-note { font-size: 13px; color: rgba(255,255,255,.8); }
.story-price { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.story-content .pct { font-size: 15px; padding: 4px 12px; }
.story-content .pct.up { color: #bbf7d0; background: rgba(34,197,94,.25); }
.story-content .pct.down { color: #fecaca; background: rgba(239,68,68,.25); }
.story-content .pct.flat { color: #e5e7eb; background: rgba(255,255,255,.15); }
.story-content .layers { width: 100%; }
.story-content .layer-row { grid-template-columns: 88px 1fr 72px; font-size: 14px; }
.story-content .layer-track { background: rgba(255,255,255,.15); }
.story-content .layer-axis { background: #fff; }
.story-content .layer-fill.up { background: #4ade80; }
.story-content .layer-fill.down { background: #f87171; }
.story-content .layer-fill.flat { background: #d1d5db; }
.story-content .layer-value.up { color: #bbf7d0; }
.story-content .layer-value.down { color: #fecaca; }
.story-content .layer-value.flat { color: #e5e7eb; }
.story-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.story-metrics .metric { background: rgba(255,255,255,.12); }
.story-metrics .metric-label { color: rgba(255,255,255,.8); }
.btn-story { background: #fff; color: #2e1065; margin-top: 6px; }
.btn-story:hover { background: #ede9fe; color: #2e1065; }
.story-tap { position: absolute; top: 96px; bottom: 126px; width: 28%; z-index: 1; background: transparent; }
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }
.story-footer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 12px 16px 14px; text-align: center; font-size: 11px; line-height: 1.4;
  color: rgba(255,255,255,.8); background: linear-gradient(transparent, rgba(0,0,0,.45));
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300;
  background: #1c1d22; color: #fff; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg); font-size: 14px; max-width: calc(100vw - 32px); text-align: center;
}
:root[data-theme="dark"] .toast { background: #f1f1f5; color: #1c1d22; }

/* ---------------- Animaciones ---------------- */
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes progress { from { width: 0; } to { width: 100%; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
  .featured-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100%;
    transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 16px 16px 32px; }
  .greeting { font-size: 21px; }
}
@media (max-width: 640px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-content, .door-modal-content { max-height: 92vh; border-radius: 20px 20px 0 0; padding: 20px 16px; }
  .door-modal-content { padding: 0; }
  .door-card { margin: 16px; padding: 20px; }
  .asset-row { flex-wrap: wrap; }
  .asset-row-main { flex-basis: 100%; }
  .asset-row-price { flex-direction: row; align-items: center; gap: 8px; margin-right: auto; }
  .story-frame { height: 100%; width: 100%; aspect-ratio: auto; border-radius: 0; }
}

/* ---------------- v6: iconos, estados, buscador, tour, glosario ---------------- */
.icon {
  width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.btn .icon { width: 16px; height: 16px; }
.btn-ghost.is-fav .icon, .btn-ghost[aria-pressed="true"] .icon { fill: currentColor; }
.card-title { display: flex; align-items: center; gap: 8px; }
.card-title-icon { width: 20px; height: 20px; color: var(--link); }
.greeting, .counter-value, .pct, .layer-value, .metric-value, .story-price, .nav-count,
.asset-row-price, .rsi-scale-value, .search-item .pct { font-variant-numeric: tabular-nums; }

/* Sidebar: contador de lista y plan */
.nav-count {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: 1px 8px;
}
.nav-item.active .nav-count { background: var(--surface); color: var(--text); }
.plan-chip {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft)); border: 1px solid var(--border);
}
.plan-chip-name { font-weight: 700; font-size: 14px; color: var(--text); }
.plan-chip-note { font-size: 12px; color: var(--muted); }

/* Cabecera: actualizado + buscador */
.header-greeting { flex: 1; min-width: 0; }
.updated-at { white-space: nowrap; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 8px 6px 12px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 14px;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text); }
.search-trigger .icon { width: 16px; height: 16px; }
kbd {
  font-family: inherit; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2);
}
.search-content { max-width: 560px; padding: 12px; align-self: flex-start; margin-top: 10vh; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.search-field .icon { width: 18px; height: 18px; color: var(--muted); }
.search-field input { flex: 1; min-width: 0; min-height: 40px; border: 0; background: transparent; font-size: 16px; }
.search-field input:focus-visible { outline: none; }
.search-results { display: flex; flex-direction: column; gap: 2px; padding: 8px 0 2px; max-height: 50vh; overflow-y: auto; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-item .asset-name { flex: 1; }
.search-item[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
#search-empty { padding: 14px 10px; color: var(--muted); }

/* Esqueletos de carga */
.skel {
  display: block; border-radius: 8px; background: var(--skel);
  background-image: linear-gradient(90deg, var(--skel) 0, var(--skel-hi) 50%, var(--skel) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
.skel-line { height: 12px; margin: 6px 0; }
.skel-num { width: 2.2em; height: 1em; }
.skel-circle { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skel-item { display: flex; align-items: center; gap: 12px; padding: 8px; }
.skel-lines { flex: 1; }
.skel-tr td { padding: 14px 12px; }
.w50 { width: 50%; } .w60 { width: 60%; } .w70 { width: 70%; } .w80 { width: 80%; } .w90 { width: 90%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Estados vacíos y de error */
.empty-icon { width: 40px; height: 40px; color: var(--link); opacity: .85; }
.state-msg { display: flex; align-items: center; gap: 10px; padding: 10px 4px; color: var(--muted); }
.state-icon { width: 22px; height: 22px; color: var(--link); }
.state-error .state-icon { color: var(--down); }

/* Pulso del mercado */
.pulse-sentence { font-size: 15px; font-weight: 600; margin-top: 4px; }

/* Glosario ⓘ */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 50%; color: var(--muted); vertical-align: middle; flex-shrink: 0;
}
.info-btn .icon { width: 16px; height: 16px; }
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--link); background: var(--accent-soft); }
.metric-label, .sheet-section h4, .rsi-scale-label { display: inline-flex; align-items: center; gap: 2px; }
.glossary-pop {
  position: fixed; z-index: 400; max-width: calc(100vw - 32px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.glossary-pop h3, #glossary-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
#glossary-text { font-size: 13px; color: var(--text); }

/* Tour de bienvenida */
.tour {
  position: fixed; z-index: 350; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
#tour-step { font-size: 12px; font-weight: 600; color: var(--link); text-transform: uppercase; letter-spacing: .03em; }
#tour-title { font-size: 16px; font-weight: 700; }
#tour-text { font-size: 14px; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.tour-target { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--accent), var(--shadow) !important; border-radius: var(--radius); }

/* Puerta: pregunta opcional de precio */
.door-tramo { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.door-tramo-thanks { font-weight: 600; color: var(--up); }
.door-tramo-note { color: var(--muted); font-size: 12px; }
.tramo-options { display: flex; flex-wrap: wrap; gap: 8px; }

/* Ficha y historias: resumen, capas explicadas y alternativa */
.sheet-summary { font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.layer-label { display: inline-flex; align-items: center; gap: 6px; }
.layer-label .icon { width: 16px; height: 16px; color: var(--muted); }
.layer-explica { font-size: 12px; color: var(--muted); margin: -4px 0 2px; }
.capas-fallback { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.fallback-frase { font-weight: 500; }
.rsi-scale { display: flex; flex-direction: column; gap: 6px; }
.rsi-scale-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.rsi-scale-value { font-weight: 700; }
.rsi-track {
  position: relative; height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2-soft), var(--accent-soft));
  border: 1px solid var(--border);
}
.rsi-marker {
  position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--accent-strong); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.rsi-scale-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.rsi-note { font-size: 12px; color: var(--muted); }
.story-summary { font-size: 16px; font-weight: 500; }
.story-content .layer-explica, .story-content .rsi-note, .story-content .rsi-scale-ends,
.story-content .capas-no-disponible { color: rgba(255,255,255,.8); }
.story-content .layer-label .icon { color: rgba(255,255,255,.85); }
.story-content .rsi-track { background: rgba(255,255,255,.18); border-color: transparent; }
.story-content .rsi-marker { background: #fff; border-color: #1a1a2e; }
.story-content .info-btn { color: rgba(255,255,255,.85); }
.story-content .muted { color: rgba(255,255,255,.8); }
.story-content .news-tono { color: rgba(255,255,255,.8); }

/* Pie: fuentes y legal */
.footer-news { color: var(--text); }
.footer-sources, .footer-legal { font-size: 12px; }

/* ---------------- Movimiento reducido ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .story-seg-fill.current { width: 100%; opacity: .6; }
  .skel { background-image: none; }
}
@media (max-width: 640px) {
  .search-trigger-text, .search-trigger kbd { display: none; }
  .search-trigger { padding: 6px 10px; }
  .search-content { margin-top: 0; align-self: flex-end; }
  .tour { bottom: 12px; }
}

/* Lote B: cabecera de capas (euros / moneda de origen), sector sin dato y tono de la noticia */
.capas-cabecera { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.capas-cifra { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.capas-cifra-label { display: inline-flex; align-items: center; gap: 4px; }
.capas-ajuste { font-size: 13px; margin: 2px 0 0; }
.capas-ref { font-size: 12px; margin: 0; }
.layer-sin-dato .layer-value { font-style: italic; }
.news-tono { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* ---------------- Lote B-fix: padding de tarjetas ---------------- */
.card, .counter-card, .empty-state-card { padding: var(--card-pad); }
.card.table-wrapper { padding: 0; overflow: hidden; }
.table-head { padding: var(--card-pad) var(--card-pad) 12px; border-bottom: 1px solid var(--border); }
/* position: relative evita que los textos ocultos (absolutos) ensanchen la página */
.table-scroll, .table-wrapper:not(.card) { position: relative; overflow-x: auto; }
.card, .featured-grid > *, .view-section { min-width: 0; }

/* ---------------- Lote B-fix: alturas reales y zonas seguras ---------------- */
input, select, textarea { font-size: 16px; }
.modal {
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
}
.modal-content, .door-modal-content {
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px - var(--safe-top) - var(--safe-bottom));
  overscroll-behavior: contain;
}
.door-modal-content { overflow-x: hidden; overflow-y: auto; }
.story-viewer { height: 100vh; height: 100dvh; }
.story-frame { height: min(860px, calc(100vh - 32px)); height: min(860px, calc(100dvh - 32px)); }
/* Si no cabe, se desplaza solo el contenido: nunca pasa por debajo de la cabecera ni del pie */
.story-content { max-height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.story-content > * { flex-shrink: 0; }
.story-stage.scrollable .story-content { touch-action: pan-y; }
.toast { bottom: calc(24px + var(--safe-bottom)); width: max-content; }
.tour { bottom: calc(24px + var(--safe-bottom)); }

@media (max-width: 860px) {
  .sidebar {
    height: 100vh; height: 100dvh; bottom: auto; max-width: 85vw; overflow-y: auto;
    padding: calc(20px + var(--safe-top)) 14px calc(20px + var(--safe-bottom)) calc(14px + var(--safe-left));
  }
  .main {
    padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left));
  }
}

/* ---------------- Lote B-fix: móvil ---------------- */
@media (max-width: 640px) {
  :root { --card-pad: 16px; }

  .featured-grid, .counters-grid, .chosen-grid { grid-template-columns: minmax(0, 1fr); }
  .counters-grid { gap: 8px; }
  .counter-card { flex-direction: row; align-items: baseline; gap: 10px; }
  .counter-value { font-size: 24px; min-width: 2ch; }
  .counter-label { font-size: 15px; }

  /* Táctil: 44 px como mínimo */
  .btn, .btn-sm, .filter-chip, .saved-tab-btn, .nav-item, .search-trigger, .search-field input,
  .radar-concept-link, .counters-explanation summary, .concept-more summary, .link-btn, .back-link,
  .sidebar-logo, .search-item, .news-link, .asset-row-main { min-height: 44px; }
  .radar-concept-link, .counters-explanation summary, .concept-more summary, .back-link, .news-link { display: flex; align-items: center; }
  .search-trigger { min-width: 44px; justify-content: center; }
  .modal-close, .story-btn { width: 44px; height: 44px; flex-shrink: 0; }
  .info-btn { width: 44px; height: 44px; margin: -10px -8px; }
  button.story-avatar { min-width: 44px; min-height: 44px; }
  button.story-avatar-sm { --size: 44px; }
  .theme-toggle { height: 44px; width: 88px; padding: 0 14px; }
  .theme-toggle-thumb { top: 4px; left: 4px; width: 34px; height: 34px; }
  .theme-toggle[aria-checked="true"] .theme-toggle-thumb { transform: translateX(44px); }
  .footer a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  .saved-tabs { display: flex; }
  .saved-tab-btn { flex: 1; min-width: 0; }

  /* Modales como hoja inferior, con altura real */
  .modal { padding: calc(12px + var(--safe-top)) 0 0; align-items: flex-end; }
  .modal-content {
    max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px - var(--safe-top));
    padding: var(--card-pad) calc(var(--card-pad) + var(--safe-right)) calc(var(--card-pad) + var(--safe-bottom)) calc(var(--card-pad) + var(--safe-left));
  }
  .door-modal-content {
    max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px - var(--safe-top));
    padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  }
  .search-content { padding-left: calc(12px + var(--safe-left)); padding-right: calc(12px + var(--safe-right)); }

  /* Cuatro capas: etiqueta arriba, valor debajo */
  .layer-row, .story-content .layer-row {
    grid-template-columns: 76px minmax(0, 1fr); grid-template-areas: "etiqueta etiqueta" "valor barra"; gap: 4px 10px;
  }
  .layer-label { grid-area: etiqueta; }
  .layer-value { grid-area: valor; text-align: left; white-space: nowrap; }
  .layer-track { grid-area: barra; }
  .capas-cifra { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* Historias a pantalla completa */
  .radar-item { flex-wrap: wrap; align-items: flex-start; }
  .radar-body { flex-basis: calc(100% - 60px); }
  .radar-line { flex-wrap: wrap; row-gap: 2px; }
  .radar-item > .btn-list { margin-left: 60px; }

  .story-frame { height: 100%; width: 100%; max-width: 100%; }
  .story-progress { padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left)); }
  .story-header { padding-left: calc(12px + var(--safe-left)); padding-right: calc(12px + var(--safe-right)); }
  .story-stage {
    padding: calc(96px + var(--safe-top)) calc(20px + var(--safe-right)) calc(126px + var(--safe-bottom)) calc(20px + var(--safe-left));
  }
  .story-tap { top: calc(96px + var(--safe-top)); bottom: calc(126px + var(--safe-bottom)); }
  .story-footer { padding-bottom: calc(14px + var(--safe-bottom)); }
  .story-content { gap: 10px; }
  .story-title { font-size: 22px; }
  .story-headline { font-size: 19px; }
  .tour { bottom: calc(12px + var(--safe-bottom)); }
}

@media (max-width: 380px) {
  .greeting { font-size: 19px; }
  .main { padding-left: calc(12px + var(--safe-left)); padding-right: calc(12px + var(--safe-right)); }
  .content-header { gap: 8px; }
  .story-tray { gap: 10px; }
  .assets-table th, .assets-table td { padding: 10px 8px; }
}

/* Escritorio estrecho: celdas algo más juntas para que quepa el botón de la tabla */
@media (min-width: 861px) and (max-width: 1400px) {
  .assets-table th, .assets-table td { padding-left: 6px; padding-right: 6px; }
}

/* ============================================================
   LOTE C: compartir y resumen por email
   ============================================================ */
.story-share { position: relative; z-index: 5; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; margin-bottom: 8px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; pointer-events: auto; }
.story-share:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.email-slot[hidden] { display: none; }
.email-slot { margin-top: 16px; }
.email-form { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.modal-content .email-form { border: 0; box-shadow: none; padding: 0; margin: 0; }
.email-form .asset-search-input { width: 100%; max-width: 420px; }
.email-label { font-weight: 600; font-size: 0.9rem; }
.email-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; font-size: 0.9rem; cursor: pointer; }
.email-check input { width: 22px; height: 22px; flex: none; margin: 0; }
.email-legal { font-size: 0.8rem; overflow-wrap: anywhere; }
.email-estado:empty { display: none; }
.email-trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
