/* Бонды — ежесуточный отчёт. Светлая/тёмная темы, палитра dataviz (валидирована). */
:root {
  color-scheme: light;
  --surface-app: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7d7c76;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --series-1: #2a78d6; /* blue — высокий рейтинг */
  --series-2: #eb6834; /* orange — средний */
  --series-3: #1baf7a; /* aqua — низкий */
  --series-n: #a5a49d; /* нейтральный — без рейтинга */
  --good: #1e7d3c;
  --bad: #c53030;
  --ring: rgba(42, 120, 214, 0.35);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 4px 16px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-app: #131312;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #34342f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --accent-soft: #10305c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-n: #6c6b64;
    --good: #37b35f;
    --bad: #ef6a69;
    --ring: rgba(57, 135, 229, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-app: #131312;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border: #34342f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --accent-soft: #10305c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-n: #6c6b64;
  --good: #37b35f;
  --bad: #ef6a69;
  --ring: rgba(57, 135, 229, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface-app);
  color: var(--text-primary);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 64px; }

/* Шапка */
.masthead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 18px; margin-bottom: 6px; }
.masthead h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.masthead .sub { color: var(--text-secondary); font-size: 14px; }
.masthead .spacer { flex: 1; }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--text-muted); }

.updated { color: var(--text-muted); font-size: 13px; margin: 2px 0 18px; }
.updated a { color: var(--text-muted); }

/* KPI-плитки */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12.5px; color: var(--text-secondary); }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: proportional-nums; }
.kpi .delta { font-size: 12.5px; margin-top: 2px; color: var(--text-muted); }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }

/* Фильтры — одна строка над всем контентом */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--text-muted); }
.field input, .field select {
  border: 1px solid var(--border); background: var(--surface-app); color: var(--text-primary);
  border-radius: 8px; padding: 7px 10px; font-size: 14px; min-width: 90px;
}
.field input:focus-visible, .field select:focus-visible, .btn:focus-visible, th:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px;
}
.field.grow { flex: 1; min-width: 200px; }
.btn {
  border: 1px solid var(--border); background: var(--surface-app); color: var(--text-secondary);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.btn:hover { color: var(--text-primary); }
.matched { font-size: 12.5px; color: var(--text-muted); margin-left: auto; align-self: center; }

/* Сетки секций */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.card .note { font-size: 12.5px; color: var(--text-muted); margin: 0 0 10px; }

/* SVG-графики */
.viz { width: 100%; display: block; }
.viz .gridline { stroke: var(--border); stroke-width: 1; }
.viz text { font-family: inherit; font-size: 11px; fill: var(--text-muted); }
.viz .axis-title { font-size: 11.5px; fill: var(--text-secondary); }
.bar { transition: opacity 0.12s; cursor: pointer; }
.bar:hover, .bar:focus-visible { opacity: 0.8; }
.dot { cursor: pointer; }
.dot:hover, .dot:focus-visible { opacity: 0.85; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Тултип */
.tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; box-shadow: var(--shadow); max-width: 260px;
  opacity: 0; transition: opacity 0.1s;
}
.tooltip .t-name { color: var(--text-secondary); font-size: 11.5px; margin-bottom: 2px; }
.tooltip .t-val { font-weight: 600; font-size: 14px; }
.tooltip .t-row { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.tooltip .key { width: 10px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }

/* Списки топов */
.tops { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 980px) { .tops { grid-template-columns: 1fr; } }
.toplist { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.toplist li {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 0;
  border-bottom: 1px solid var(--surface-2);
}
.toplist li:last-child { border-bottom: none; }
.toplist .rank { color: var(--text-muted); width: 20px; flex: none; font-variant-numeric: tabular-nums; }
.toplist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.toplist .val.up { color: var(--good); }
.toplist .val.down { color: var(--bad); }

/* Сценарная таблица */
table.scen { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.scen th, table.scen td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--surface-2); }
table.scen td.num, table.scen th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.scen th { color: var(--text-secondary); font-weight: 500; font-size: 12.5px; }

/* Большая таблица бондов */
.tablewrap { overflow-x: auto; }
table.bonds { width: 100%; border-collapse: collapse; font-size: 13px; }
table.bonds th {
  position: sticky; top: 0; background: var(--surface-1);
  color: var(--text-secondary); font-weight: 500; font-size: 12px;
  text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.bonds th.num { text-align: right; }
table.bonds th .arr { font-size: 10px; color: var(--accent); }
table.bonds td { padding: 6px 8px; border-bottom: 1px solid var(--surface-2); white-space: nowrap; }
table.bonds td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.bonds tr:hover td { background: var(--surface-2); }
.badge {
  display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; font-weight: 600;
}
.badge.cheap { background: rgba(30, 125, 60, 0.12); color: var(--good); }
.badge.rich { background: rgba(197, 48, 48, 0.1); color: var(--bad); }
.badge.fair { background: var(--surface-2); color: var(--text-muted); }
.more-row { text-align: center; padding: 14px; }

footer { margin-top: 26px; color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
