:root {
  --bg: #0e1621;
  --bg2: #17212b;
  --card: #182533;
  --card2: #1e2c3a;
  --line: #202e3c;
  --ink: #f5f5f5;
  --hint: #6e7783;
  --accent: #2aabee;
  --accent-bg: #17374a;
  --up: #4fc17a;
  --up-bg: #1e3b30;
  --down: #ff5c56;
  --down-bg: #3e2229;
  --dim: #cbd2da;
  --dim-bg: #2a3644;
  --tabbar-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
}
button { font: inherit; color: inherit; }

/* ── Верхняя панель ─────────────────────────── */
.appbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px calc(10px + env(safe-area-inset-top));
  background: transparent;
}
.appbar__titles { flex: 1; min-width: 0; }
.appbar__name {
  font-size: 19px; font-weight: 800; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 6px;
}
.appbar__name::before {
  content: ""; width: 8px; height: 8px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  display: inline-block;
}
.appbar__sub { font-size: 12px; color: var(--hint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: var(--card); color: var(--hint);
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(.94); }

/* ── Экраны и нижняя навигация ───────────────── */
.screen { padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
.screen.is-hidden { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabbar__btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; cursor: pointer;
  color: var(--hint); font-size: 11px; padding: 6px 0;
  border-radius: 12px; transition: color .15s;
}
.tabbar__btn svg { width: 24px; height: 24px; stroke-width: 1.9; }
.tabbar__btn.is-active { color: var(--accent); }
.tabbar__btn.is-active span { font-weight: 700; }
.tabbar__btn:active { transform: scale(.93); }

/* ── Карточки ───────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; margin-bottom: 10px;
}
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card__name { font-weight: 700; font-size: 14px; }
.card__uk { color: var(--hint); font-size: 12px; margin-top: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.chip.up { color: var(--up); background: var(--up-bg); }
.chip.down { color: var(--down); background: var(--down-bg); }
.chip.dim { color: var(--dim); background: var(--dim-bg); }
.chip.accent { color: var(--accent); background: var(--accent-bg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.spark { display: block; width: 100%; margin-top: 8px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark-area { fill: rgba(42,171,238,.09); }

.barblock__title { font-size: 12px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px;
}
.bar__name { width: 118px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { flex: 1; height: 8px; border-radius: 99px; background: var(--dim-bg); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #7c5cff); }
.bar__pct { width: 44px; text-align: right; color: var(--hint); font-variant-numeric: tabular-nums; }

.as-of { font-size: 12px; color: var(--hint); margin: 2px 4px 10px; }
.meta { text-align: center; color: var(--hint); font-size: 11px; padding-top: 6px; }
.note { color: var(--hint); font-size: 12px; line-height: 1.55; }

/* ── Главный экран: пересечения ───────────────── */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #16283a, #1d2f46 55%, #24364d);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 18px 16px 14px; margin-bottom: 12px;
}
.hero__label { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.hero__title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 8px; }
.hero__sub { font-size: 12.5px; line-height: 1.5; color: #9fb3c8; margin-bottom: 12px; }
.hero__stats { display: flex; gap: 10px; }
.stat { flex: 1; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: #9fb3c8; }
.hero__core .chip.accent { color: #7adaff; background: rgba(42,171,238,.18); border: 1px solid rgba(122,218,255,.22); }
.hero__core { margin-top: 12px; }

.iv-section-title { font-size: 12px; font-weight: 800; color: var(--hint); text-transform: uppercase; letter-spacing: .06em; margin: 4px 4px 8px; }

.iv-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; margin-bottom: 8px;
  transition: transform .1s;
}
.iv-row:active { transform: scale(.985); }
.iv-rank {
  width: 26px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: var(--hint);
  background: var(--bg2); border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.iv-main { flex: 1; min-width: 0; }
.iv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.iv-name { font-weight: 700; font-size: 14px; }
.iv-time { flex: 1; height: 5px; border-radius: 99px; background: var(--dim-bg); overflow: hidden; margin-bottom: 8px; }
.iv-time__fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #7c5cff); }
.iv-facts { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.iv-name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.risk-btn {
  border: 0; background: var(--bg2); color: var(--hint);
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.risk-btn svg { width: 13px; height: 13px; }
.risk-btn:active { color: var(--accent); transform: scale(.9); }
.iv-tip {
  display: none;
  margin-top: 9px; font-size: 12px; line-height: 1.55;
  color: var(--ink);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 10px; padding: 8px 10px;
}
.iv-tip.open { display: block; }
.iv-funds { display: flex; flex-wrap: wrap; gap: 4px; }
.iv-fund {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--hint);
  background: var(--bg2); border-radius: 7px; padding: 2px 6px; white-space: nowrap;
}
.iv-fund b { color: var(--ink); font-weight: 700; }
.iv-div { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.iv-div .hist-meta { font-size: 10px; color: var(--hint); }
.iv-div .chip { font-size: 12px; }

/* счётчик «в N фондах» */
.iv-count { font-size: 12px; font-weight: 700; color: var(--dim); font-variant-numeric: tabular-nums; }

/* отметка «в моём портфеле» */
.hold { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; flex-wrap: wrap; }
.hold-btn {
  border: 1px solid var(--line); background: var(--bg2); color: var(--hint);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none;
}
.hold-btn:active { transform: scale(.96); }
.hold-btn.on {
  background: var(--up-bg); color: var(--up); border-color: color-mix(in srgb, var(--up) 40%, transparent);
}
.vote-meta { font-size: 11px; color: var(--hint); }
.vote-hint { font-size: 12px; color: var(--hint); margin: 0 4px 8px; }

/* ── Список фондов ──────────────────────────── */
.fund-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: transform .1s;
}
.fund-card:active { transform: scale(.985); }
.fund-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.fund-card__name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.fund-card__uk { color: var(--hint); font-size: 12px; margin-top: 2px; }
.fund-card__price { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.price { font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.fund-card__src { font-size: 11px; color: var(--hint); margin-top: 4px; }
.legend {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 8px;
}
.legend b { font-size: 12px; font-weight: 700; }
.legend span { font-size: 12px; color: var(--hint); line-height: 1.5; }
.fund-card__foot { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mini { font-size: 11px; color: var(--hint); }

/* ── Детали фонда ───────────────────────────── */
.detail-price { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.detail__sub { color: var(--hint); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-align: center; }
.metric b { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
.metric span { display: block; font-size: 10px; color: var(--hint); margin-top: 2px; }

.seg {
  display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin: 4px 0 12px;
}
.seg button {
  flex: 1; border: 0; background: none; color: var(--hint); font-weight: 600;
  border-radius: 9px; padding: 8px 0; font-size: 13px; cursor: pointer;
}
.seg button.is-active { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 800; }

/* история */
.hist-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 13px; padding: 8px 2px; border-bottom: 1px solid var(--line);
}
.hist-line:last-child { border-bottom: 0; }
.hist-meta { color: var(--hint); font-size: 12px; }
.diff-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 7px 2px; border-bottom: 1px solid var(--line);
}
.diff-row:last-child { border-bottom: 0; }
.diff-name { font-weight: 600; }
.diff-spacer { flex: 1; }
.diff-up { color: var(--up); }
.diff-down { color: var(--down); }
.comment { font-size: 13px; color: var(--ink); white-space: pre-line; background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.sheet-title { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }
.error-tip { color: var(--hint); font-size: 12px; margin-top: 6px; }