/* Фонды РФ · Russian Magellan — две темы: ночная (navy) и дневная. */

:root {
  --radius: 14px;
  --radius-s: 9px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --page: #10151f;
  --page-glow: radial-gradient(1100px 500px at 15% -8%, rgba(42, 171, 238, .10), transparent 60%),
               radial-gradient(900px 500px at 95% 0%, rgba(37, 99, 235, .07), transparent 55%);
  --surface: #182030;
  --surface-2: #1f2a3d;
  --ink: #f4f6fb;
  --ink-2: #c6cddc;
  --muted: #8b93a7;
  --grid: #233048;
  --baseline: #33456a;
  --border: rgba(148, 163, 199, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 28px -18px rgba(0, 0, 0, .6);
  --accent: #3B82F6;
  --accent-2: #2AABEE;
  --in: #2fca74;
  --out: #ff7080;
  --tile-in: #1CB662;
  --tile-out: #EF4655;
  --thumb: #2c3a55;
}

:root[data-theme="light"] {
  --page: #EEF1F7;
  --page-glow: radial-gradient(1100px 500px at 15% -8%, rgba(42, 171, 238, .10), transparent 60%),
               radial-gradient(900px 500px at 95% 0%, rgba(37, 99, 235, .06), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f2f5fa;
  --ink: #101828;
  --ink-2: #3f4a5f;
  --muted: #778093;
  --grid: #e6eaf2;
  --baseline: #c9d2e0;
  --border: rgba(16, 24, 40, .10);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 30px -22px rgba(16, 24, 40, .25);
  --accent: #2563EB;
  --accent-2: #2AABEE;
  --in: #0E8A44;
  --out: #C81E31;
  --tile-in: #0E8A44;
  --tile-out: #C81E31;
  --thumb: #cbd4e2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--thumb) transparent; }
body {
  background: var(--page-glow), var(--page);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  transition: background-color .25s, color .25s;
}
::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- шапка */
header.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px 8px; gap: 12px; flex-wrap: wrap;
  max-width: 1480px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 2px 8px rgba(42, 171, 238, .35)); }
.brand h1 {
  font-size: 21px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap;
}
.brand .bname {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.hright { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upd { color: var(--muted); font-size: 12px; text-align: right; }

/* кнопка поддержки/телеграма — фирменный градиент, заметная */
.tg-btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 16px; border-radius: 12px; text-decoration: none;
  color: #fff; font-size: 13.5px; line-height: 1.2; white-space: nowrap;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 16px -4px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: transform .15s, box-shadow .15s;
}
.tg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 22px -5px color-mix(in srgb, var(--accent) 70%, transparent);
}
.tg-btn svg { flex: none; }
.tg-btn b { font-weight: 700; }
@media (max-width: 900px) {
  .tg-btn span { font-size: 12.5px; }
  .tg-btn { padding: 8px 12px; }
}
#themeBtn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 17px; line-height: 1;
  box-shadow: var(--shadow); transition: transform .15s;
}
#themeBtn:hover { transform: scale(1.08); }

/* ------------------------------------------------------------- вкладки */
.tabs {
  display: flex; gap: 2px; padding: 8px 22px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grid);
  max-width: 1480px; margin: 0 auto;
}
.tabs button {
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 600; padding: 9px 15px; cursor: pointer;
  border-radius: 10px; position: relative; transition: color .15s;
}
.tabs button:hover { color: var(--ink-2); background: var(--surface); }
.tabs button.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.tabs button.on::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

main { padding: 16px 22px 30px; max-width: 1480px; margin: 0 auto; }
.tab { display: none; }
.tab.on { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ------------------------------------------------------------- фильтры */
.filterrow {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 6px 0 14px;
}
.seg {
  display: inline-flex; background: var(--surface); border-radius: 11px; padding: 3px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.seg button {
  background: none; border: none; color: var(--muted); font: inherit; font-weight: 550;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: color .15s;
}
.seg button.on {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface-2)), var(--surface-2));
  color: var(--ink); box-shadow: inset 0 0 0 1px var(--border);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--border);
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 20px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: all .15s;
}
.chips button .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chips button:hover { border-color: var(--accent); }
.chips button.on {
  color: var(--ink); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

input[type="search"], select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 13px; font: inherit; min-width: 150px;
  box-shadow: var(--shadow);
}
input[type="search"]:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
input[type="search"] { flex: 1 1 260px; }
select.inline { min-width: 200px; }
.count { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------- плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border-radius: var(--radius); padding: 15px 17px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  opacity: .75;
}
.tile .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.tile .value { font-size: 27px; font-weight: 700; margin-top: 5px; letter-spacing: -.01em; }
.tile .value.in { color: var(--tile-in); }
.tile .value.out { color: var(--tile-out); }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ------------------------------------------------------------- карточки */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 15px 17px 11px;
  margin-bottom: 14px; min-width: 0;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h3 { font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.note { color: var(--muted); font-size: 12px; margin: 5px 0 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }

.chart { height: 300px; margin-top: 6px; }
.chart.tall { height: 400px; }

.tbl-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; border-radius: 7px; padding: 4px 10px; cursor: pointer;
  transition: all .15s;
}
.tbl-btn.on, .tbl-btn:hover { color: var(--ink-2); border-color: var(--accent); }
.tblview { display: none; max-height: 300px; overflow: auto; margin-top: 8px; }
.tblview.on { display: block; }
.tblview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tblview th, .tblview td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tblview th:first-child, .tblview td:first-child { text-align: left; }
.tblview th { color: var(--muted); position: sticky; top: 0; background: var(--surface); }
.tblview td { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- таблицы */
.minitable { overflow-x: auto; margin-top: 8px; }
.minitable table { width: 100%; border-collapse: collapse; font-size: 13px; }
.minitable th, .minitable td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.minitable th:first-child, .minitable td:first-child,
.minitable th.l, .minitable td.l { text-align: left; }
.minitable th { color: var(--muted); font-weight: 550; font-size: 12px; }
.minitable td { font-variant-numeric: tabular-nums; }
.minitable tr.clickable { cursor: pointer; }
.minitable tr.clickable:hover td { background: var(--surface-2); }

.tablecard { padding: 6px 0 0; }
.scrollx { overflow-x: auto; }
.bigtable { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1150px; }
.bigtable th, .bigtable td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.bigtable th.l, .bigtable td.l { text-align: left; }
.bigtable th {
  color: var(--muted); font-weight: 550; font-size: 12px; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.bigtable th.sorted { color: var(--accent); }
.bigtable td { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bigtable td.name { color: var(--ink); max-width: 340px; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.bigtable tbody tr { cursor: pointer; }
.bigtable tbody tr:hover td { background: var(--surface-2); }

.pos { color: var(--in); }
.neg { color: var(--out); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ------------------------------------------------------------- модалка */
.modal {
  display: none; position: fixed; inset: 0; background: rgba(6, 10, 18, .68);
  backdrop-filter: blur(3px);
  z-index: 100; padding: 4vh 4vw; overflow: auto;
}
.modal.on { display: block; }
.modalbox {
  background: var(--page); border: 1px solid var(--border); border-radius: 16px;
  max-width: 1080px; margin: 0 auto; padding: 20px 22px; position: relative;
  box-shadow: 0 24px 80px -24px rgba(0, 0, 0, .55);
}
.modal .close {
  position: absolute; right: 14px; top: 10px; background: none; border: none;
  color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1;
}
.modal .close:hover { color: var(--ink); }
.fund-head h2 { font-size: 19px; margin-right: 30px; }
.fund-head .meta { color: var(--muted); font-size: 13px; margin: 4px 0 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.fund-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.fund-kpis .tile { padding: 11px 13px; }
.fund-kpis .tile .value { font-size: 19px; }
.fund-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .fund-grid { grid-template-columns: 1fr; } }
.fund-grid .card { margin-bottom: 0; }
.infolist { font-size: 13px; }
.infolist div { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.infolist dt { color: var(--muted); }
.infolist dd { text-align: right; }
.funddesc { color: var(--ink-2); font-size: 13px; margin: 2px 0 10px; }

footer {
  color: var(--muted); font-size: 12px; padding: 10px 22px 26px;
  max-width: 1480px; margin: 0 auto;
}

.loading { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 640px) {
  header.top { padding: 12px 14px 6px; }
  .tabs { padding: 6px 10px; }
  main { padding: 12px 12px 24px; }
  .tile .value { font-size: 22px; }
  .chart { height: 260px; }
  .chart.tall { height: 320px; }
}
