/* Mis Finanzas — dark, mobile-first, sin layout shift.
   Regla de UI: todo valor ausente se dibuja como "—" en color apagado.
   Nada de spinners que empujan contenido: usamos skeletons del mismo alto. */

:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-elev-2: #182130;
  --line: #232c3a;
  --line-soft: #1b2430;
  --text: #e7edf5;
  --text-dim: #93a1b5;
  --text-faint: #5d6b7f;
  --up: #35d07f;
  --down: #ff5f6d;
  --accent: #5b8cff;
  --warn: #f5a524;
  --demo: #ff8a3d;
  --r: 16px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 62px;
  font-synthesis-weight: none;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { padding-top: var(--safe-t); }

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -0.015em; }
.muted { color: var(--text-dim); font-size: 12.5px; font-weight: 500; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.up { color: var(--up); }
.down { color: var(--down); }
.none { color: var(--text-faint); }

/* ---------------- botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--bg-elev);
  color: var(--text); border-radius: 12px; padding: 11px 16px;
  font: inherit; font-weight: 560; cursor: pointer;
  transition: background .15s ease, transform .06s ease, border-color .15s ease;
}
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #08111f; }
.btn--primary:hover { background: #6f9bff; }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn--lg { width: 100%; padding: 15px; font-size: 16px; }
.btn--icon { padding: 6px 10px; background: transparent; border-color: transparent; color: var(--text-dim); font-size: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.input {
  width: 100%; margin: 10px 0; padding: 11px 13px; font: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------------- login ---------------- */
.screen--center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 340px; text-align: center; }
.login__mark {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 20px;
  display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(160deg, #1a2637, #121821);
  border: 1px solid var(--line);
}
.login h1 { font-size: 25px; }
.login__sub { color: var(--text-dim); margin: 6px 0 28px; font-size: 14px; }
.login .btn { margin-bottom: 10px; }
.login__error { color: var(--down); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.login__help { margin-top: 26px; text-align: left; color: var(--text-dim); font-size: 13px; }
.login__help summary { cursor: pointer; text-align: center; padding: 8px; }
.login__help p { line-height: 1.5; }

/* ---------------- banners ---------------- */
.banner {
  padding: 9px 16px; font-size: 12.5px; font-weight: 600; text-align: center;
  letter-spacing: .01em;
}
.banner--demo { background: var(--demo); color: #26150a; }
.banner--warn { background: #3a2c10; color: var(--warn); border-bottom: 1px solid #55400f; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 18px var(--pad) 10px;
}
.topbar__label { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 620; }
.topbar__value { font-size: 30px; font-weight: 680; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.topbar__right { text-align: right; }
.topbar__day { font-size: 17px; font-weight: 640; margin-top: 6px; font-variant-numeric: tabular-nums; }

.live {
  display: flex; align-items: center; gap: 7px; padding: 0 var(--pad) 14px;
  color: var(--text-faint); font-size: 11.5px; font-weight: 500;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.live.is-live .dot { background: var(--up); box-shadow: 0 0 0 0 rgba(53,208,127,.55); animation: pulse 2.4s infinite; }
.live.is-stale .dot { background: var(--warn); }
.live.is-error .dot { background: var(--down); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53,208,127,.5); }
  70% { box-shadow: 0 0 0 7px rgba(53,208,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,208,127,0); }
}
@media (prefers-reduced-motion: reduce) { .live.is-live .dot { animation: none; } }

main { padding: 0 var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 24px); }

/* ---------------- KPIs ---------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 13px 14px; min-height: 78px;
}
.kpi__label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 620; }
.kpi__value { font-size: 19px; font-weight: 660; margin-top: 7px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi__sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

/* ---------------- cards ---------------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 14px; margin-bottom: 14px;
}
.card--flush { padding: 14px 0 4px; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 14px 12px; }
.card:not(.card--flush) .card__head { padding: 0 0 12px; }
.card__head h2 { font-size: 14.5px; }

/* ---------------- distribución ---------------- */
.alloc__bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg-elev-2); }
.alloc__seg { height: 100%; }
.alloc__legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.alloc__item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.alloc__swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.alloc__item b { color: var(--text); font-weight: 600; }

/* ---------------- posiciones ---------------- */
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 12px 14px; border-top: 1px solid var(--line-soft);
  cursor: pointer; align-items: center;
}
.row:first-child { border-top: none; }
.row:active { background: var(--bg-elev-2); }
.row__sym { font-weight: 660; font-size: 15px; letter-spacing: -0.01em; }
.row__desc {
  color: var(--text-faint); font-size: 12px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.row__right { text-align: right; }
.row__val { font-weight: 620; font-variant-numeric: tabular-nums; }
.row__chg { font-size: 12.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tagline { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.tag {
  font-size: 10px; font-weight: 660; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; background: var(--bg-elev-2); color: var(--text-dim);
}

/* ---------------- warnings ---------------- */
.warnings { list-style: none; padding: 0; margin: 6px 0 0; }
.warnings li {
  background: #2a2110; border: 1px solid #4a3a14; color: #f0c46a;
  border-radius: 12px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 8px; line-height: 1.45;
}

/* ---------------- noticias ---------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--bg-elev);
  color: var(--text-dim); border-radius: 999px; padding: 7px 14px;
  font: inherit; font-size: 13px; font-weight: 560; cursor: pointer; white-space: nowrap;
}
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

.news__group { margin-bottom: 22px; }
.news__group h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.news__item {
  display: block; text-decoration: none; color: inherit;
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 9px;
}
.news__item:active { background: var(--bg-elev-2); }
.news__title { font-size: 14px; font-weight: 580; line-height: 1.35; }
.news__meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.news__src { color: var(--text-faint); font-size: 11.5px; }
.cat { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; }
.cat--legal { background: #3a1620; color: #ff8fa0; }
.cat--earnings { background: #123528; color: #4fdca0; }
.cat--ma { background: #2a1f3d; color: #b79cff; }
.cat--analyst { background: #14263f; color: #7fb0ff; }
.cat--dividend { background: #113234; color: #57d3d8; }
.cat--product, .cat--general { background: var(--bg-elev-2); color: var(--text-dim); }

/* ---------------- tabbar ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(11,15,20,.86); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line-soft);
  padding-bottom: var(--safe-b);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; color: var(--text-faint);
  font: inherit; font-size: 10.5px; font-weight: 600; padding: 9px 0 7px; cursor: pointer;
}
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }

/* ---------------- sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh;
  background: var(--bg-elev); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line); display: flex; flex-direction: column;
  animation: rise .24s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet__panel { animation: none; } }
.sheet__grip { width: 38px; height: 4px; border-radius: 3px; background: var(--line); margin: 9px auto 2px; }
.sheet__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.sheet__head h2 { font-size: 19px; }
.sheet__head p { margin: 3px 0 0; }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(24px + var(--safe-b)); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; margin-bottom: 16px; }
@media (min-width: 480px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--bg-elev); padding: 11px 13px; }
.stat__k { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 620; }
.stat__v { font-size: 15px; font-weight: 620; margin-top: 5px; font-variant-numeric: tabular-nums; }

.spark { width: 100%; height: 96px; display: block; margin-bottom: 16px; }
.section-title { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 640; margin: 18px 0 10px; }
.link-out { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 580; }

/* ---------------- skeletons ---------------- */
.sk { background: linear-gradient(90deg, var(--bg-elev-2) 25%, #1e2939 37%, var(--bg-elev-2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk--row { height: 56px; margin: 0 14px 8px; }
.sk--kpi { height: 78px; border-radius: var(--r); }

.empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 26px 14px; line-height: 1.5; }
