/* Аналитика на «Обзоре» (analytics.js). Цвета — токены style.css и палитра графиков ниже. */
:root {
  --ch0: #3346d3; --ch1: #e0861a; --ch2: #17977a; --ch3: #c2417a; --ch4: #7a55d6; --ch5: #2f8fd0; --ch6: #9a8a2e; --ch7: #8a8f9c;
  --grid: #ebe9e3; --area: rgba(51, 70, 211, .10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ch0: #8d9cff; --ch1: #f2a54a; --ch2: #4fcfa6; --ch3: #f07fae; --ch4: #b39bff; --ch5: #6cc0f5; --ch6: #d6c45a; --ch7: #9aa0ae;
    --grid: #262b35; --area: rgba(141, 156, 255, .12);
  }
}
.an { margin-top: 8px; }
.an-head { margin-bottom: 10px; padding: 0 2px; }
.an-head h2 { font-size: 18px; }
.an-seg { flex: 0 1 auto; }
.an-seg label { padding-left: 10px; padding-right: 10px; }
.an-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.an-filters select { width: auto; min-width: 0; flex: 0 1 220px; min-height: 38px; }
.an-custom { display: flex; gap: 6px; align-items: center; flex: 1 1 260px; min-width: 0; }
.an-custom input { flex: 1 1 120px; min-width: 0; min-height: 38px; }
.an-period { margin: -2px 2px 12px; }
.an-body { transition: opacity .2s; min-width: 0; }
.an-body.busy { opacity: .55; pointer-events: none; }
.an-kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.an-kpi .value { font-size: 21px; }
.an-kpi .value .money { white-space: normal; }
.kpi-sep, .kpi-unit { color: var(--muted); font-weight: 500; font-size: .7em; }
.an-kpi .sub { line-height: 1.45; }
a.an-pend { color: var(--text); display: block; transition: border-color .2s; }
a.an-pend:hover { text-decoration: none; border-color: var(--border-strong); }
a.an-pend.has { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.delta { color: var(--muted); }
.delta b { font-weight: 650; }
.delta.good b { color: var(--pos); }
.delta.bad b { color: var(--neg); }
.an-card { min-width: 0; }
.an-card h3 { margin: 18px 0 6px; }
.an-two { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); margin-bottom: 12px; }
.an-two > .card { margin: 0; }
.an-none { padding: 16px 0; }

/* легенда и подписи */
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend span, .legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend.toggles { gap: 6px; }
.lg { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text); cursor: pointer; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity .15s, background-color .15s; }
.lg:hover { background: var(--surface2); }
.lg.off { opacity: .45; }
.lg.off .dot { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; background: var(--muted); }
.dot.in { background: var(--pos); } .dot.out { background: var(--neg); } .dot.pr { background: var(--accent); border-radius: 50%; }
.dot.c0 { background: var(--ch0); } .dot.c1 { background: var(--ch1); } .dot.c2 { background: var(--ch2); } .dot.c3 { background: var(--ch3); }
.dot.c4 { background: var(--ch4); } .dot.c5 { background: var(--ch5); } .dot.c6 { background: var(--ch6); } .dot.c7 { background: var(--ch7); }
.readout { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; padding: 8px 2px 0; min-height: 30px; color: var(--muted); }
.readout > span { display: inline-flex; align-items: center; gap: 6px; }
.readout .money { color: var(--text); font-weight: 600; }
.readout .money.pos { color: var(--pos); } .readout .money.neg { color: var(--neg); }
.readout .ro-d { color: var(--text); font-weight: 650; }

/* SVG-графики */
.chartbox { width: 100%; min-width: 0; overflow: hidden; }
.chart { display: block; max-width: 100%; height: auto; touch-action: pan-y; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .gl.zero { stroke: var(--border-strong); }
.chart .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar.in { fill: var(--pos); }
.chart .bar.out { fill: var(--neg); opacity: .85; }
.chart .pline { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pdot { fill: var(--surface); stroke: var(--accent); stroke-width: 1.8; }
.chart .hl { fill: var(--surface3); opacity: 0; transition: opacity .15s, x .15s; }
.chart .hl.on { opacity: .7; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .guide { stroke: var(--border-strong); stroke-dasharray: 3 3; opacity: 0; }
.chart .guide.on { opacity: 1; }
.chart .area { fill: var(--area); stroke: none; }
.chart .bline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bline.total { stroke-width: 2.8; }
.bline.c0, .dseg.c0 { stroke: var(--ch0); } .bline.c1, .dseg.c1 { stroke: var(--ch1); } .bline.c2, .dseg.c2 { stroke: var(--ch2); }
.bline.c3, .dseg.c3 { stroke: var(--ch3); } .bline.c4, .dseg.c4 { stroke: var(--ch4); } .dseg.c5 { stroke: var(--ch5); }
.dseg.c6 { stroke: var(--ch6); } .dseg.c7 { stroke: var(--ch7); }

/* кольцо структуры */
.an-cats { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut { flex: 0 0 auto; }
.donut circle { fill: none; stroke-width: 20; }
.donut .track { stroke: var(--surface2); }
.donut .d-val { fill: var(--text); font-size: 16px; font-weight: 700; }
.donut .d-cap { fill: var(--muted); font-size: 11px; }
.an-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.an-legend li { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.an-legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-legend .sh { color: var(--muted); font-variant-numeric: tabular-nums; width: 52px; text-align: right; flex: 0 0 auto; }
.an-legend .money { font-weight: 600; }

/* валюты без пересчёта */
.an-curs { display: flex; flex-direction: column; gap: 12px; }
.an-cur { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.an-cur dl { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; min-width: 0; flex: 1 1 auto; }
.an-cur dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.an-cur dd { margin: 0; font-weight: 600; }
.an-cur .rk { width: auto; min-width: 30px; padding: 0 6px; }

/* рейтинги и полосы */
.an-rank, .an-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.an-rank li, .an-people li { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.an-rank .nm, .an-people .nm { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.an-rank .row.between, .an-people .row.between { flex-wrap: nowrap; }
.rk { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.an-rank li:first-child .rk { background: var(--accent-soft); color: var(--accent); }
.an-people .ava { width: 30px; height: 30px; font-size: 13px; flex: 0 0 auto; }
.hb { display: block; height: 6px; border-radius: 3px; background: var(--surface2); margin: 6px 0 4px; overflow: hidden; }
.hb-fill { display: block; height: 100%; border-radius: 3px; background: var(--accent); transform-origin: left center; transform: scaleX(var(--w, 0)); }
.hb-fill.pos { background: var(--pos); } .hb-fill.neg { background: var(--neg); } .hb-fill.acc { background: var(--accent); }
.an-io { display: flex; flex-direction: column; gap: 0; max-width: 160px; }
.an-io .hb { height: 4px; margin: 3px 0 0; }

@media (prefers-reduced-motion: no-preference) {
  @keyframes an-grow { from { transform: scaleY(0); } }
  @keyframes an-growx { from { transform: scaleX(0); } }
  @keyframes an-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes an-seg { from { stroke-dasharray: 0 100; } }
  @keyframes an-pop { from { opacity: 0; transform: scale(.3); } }
  @keyframes an-in { from { opacity: 0; transform: translateY(6px); } }
  .an-swap { animation: an-in .35s var(--ease-out, ease-out) backwards; }
  .chart.anim .bar { transform-box: fill-box; transform-origin: 50% 100%; animation: an-grow .65s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 16ms); }
  .chart.anim .pline, .chart.anim .bline { stroke-dasharray: 1; animation: an-draw 1s .25s cubic-bezier(.4, 0, .2, 1) backwards; }
  .chart.anim .bline { animation-delay: calc(var(--i, 0) * 40ms); }
  .chart.anim .area { animation: an-in .8s .4s ease-out backwards; }
  .chart.anim .pdot { transform-box: fill-box; transform-origin: center; animation: an-pop .35s backwards; animation-delay: calc(.5s + var(--i, 0) * 16ms); }
  .donut.anim .dseg { animation: an-seg .8s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
  .hb-fill { animation: an-growx .7s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms + .1s); }
  .an-legend li, .an-rank li, .an-people li, .an-cur { animation: an-in .35s ease-out backwards; animation-delay: calc(var(--i, 0) * 30ms); }
  .an-kpi { animation-delay: calc(var(--i, 0) * 60ms) !important; }
}
@media (max-width: 899px) {
  .an-head { align-items: flex-start; }
  .an-seg { width: 100%; }
  .an-seg label { flex: 1 1 auto; text-align: center; padding-left: 6px; padding-right: 6px; }
  .an-filters select { flex: 1 1 140px; }
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .an-kpi { padding: 12px 12px; }
  .an-kpi .value { font-size: 16px; }
  .an-kpi .value .money { white-space: nowrap; }
  .an-kpi .value .money .dec { display: none; }
  .an-io { max-width: none; }
}
