/* Графики. Рисуются как SVG кодом, без библиотек: один файл стилей на все фигуры. */

.chart { position: relative; width: 100%; }
/* overflow: hidden обязателен: курсорная линия и точка ждут своего часа за кадром,
   при видимом переполнении они торчали у левого края как мусор. */
.chart svg { display: block; width: 100%; height: auto; overflow: hidden; }

.chart-hero { aspect-ratio: 16 / 6; }
.chart-dd   { aspect-ratio: 16 / 5; }
.chart-calc { aspect-ratio: 16 / 7; }

@media (max-width: 700px) {
  .chart-hero { aspect-ratio: 4 / 3; }
  .chart-dd   { aspect-ratio: 3 / 2; }
  .chart-calc { aspect-ratio: 4 / 3; }
}

.g-grid { stroke: var(--line); stroke-width: 1; }
.g-lbl  { fill: var(--cream-3); font-family: "Golos", sans-serif; font-size: 11px; letter-spacing: .04em; }
.g-tier { fill: var(--cream-2); font: 600 10px "Golos", sans-serif; letter-spacing: .14em; paint-order: stroke; stroke: var(--night); stroke-width: 3px; }

.g-line { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.g-fill { fill: var(--gold-soft); }
.g-line-neg { fill: none; stroke: var(--rose); stroke-width: 1.6; }
.g-fill-neg { fill: var(--rose-soft); }

/* размерная выноска у худшей просадки: приём «линейка», но ровно в одном месте */
.g-dim { stroke: var(--rose); stroke-width: 1; }
/* подпись выноски ложится поверх кривой, поэтому у неё ореол цветом бумаги:
   без него число на линии не прочитать */
.g-dim-lbl {
  fill: var(--rose); font-family: "Golos", sans-serif; font-size: 11.5px; font-weight: 600;
  paint-order: stroke; stroke: var(--night); stroke-width: 4px; stroke-linejoin: round;
}

.g-hover { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }
.g-dot { fill: var(--gold); }

.chart-tip {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--cream); color: var(--night);
  font: 400 12.5px/1.45 "Golos", sans-serif;
  padding: 8px 10px; border-radius: var(--r-s); white-space: nowrap;
  transform: translate(-50%, -130%); opacity: 0;
  transition: opacity 140ms var(--ease);
}
.chart-tip.on { opacity: 1; }

/* линия рисуется один раз при первом появлении */
.g-draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); }
.in .g-draw { stroke-dashoffset: 0; transition: stroke-dashoffset 900ms var(--ease); }

/* ── помесячно ───────────────────────────────────────────────── */

.months { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: clamp(16px, 2vw, 26px); }
.mo-col { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; align-self: start; background: rgba(255,255,255,.03); }
.mo-year {
  background: rgba(255,255,255,.06); padding: 10px 16px; display: flex; justify-content: space-between;
  font-family: "Golos", sans-serif; font-size: 11.5px; letter-spacing: .1em; color: var(--cream-3);
  border-bottom: 1px solid var(--line);
}
.mo-ytot { font-family: var(--f-num), Georgia, serif; font-weight: 600; font-size: 13px; color: var(--gold); font-weight: 500; letter-spacing: .02em; font-variant-numeric: lining-nums tabular-nums; }
.mo-ytot.neg { color: var(--rose); }
.mo-row {
  display: grid; grid-template-columns: 44px 1fr 68px; align-items: center; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
}
.mo-col .mo-row:last-child { border-bottom: 0; }
.mo-name { font-family: "Golos", sans-serif; font-size: 12.5px; color: var(--cream-3); }
.mo-bar { position: relative; height: 12px; }
.mo-zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
.mo-fill { position: absolute; top: 1px; height: 10px; background: var(--gold); border-radius: 1px; }
.mo-fill.neg { background: var(--rose); }
.mo-val { font-family: "Golos", sans-serif; font-size: 13px; color: var(--cream); text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.mo-val.neg { color: var(--rose); }

@media (max-width: 520px) {
  .mo-row { grid-template-columns: 46px 1fr 66px; gap: 10px; padding: 8px 12px; }
}

/* ── распределение дней ──────────────────────────────────────── */

.dist { display: grid; gap: 10px; }
.dist-row { display: grid; grid-template-columns: 96px 1fr 58px; align-items: center; gap: 12px; }
.dist-k { font-family: "Golos", sans-serif; font-size: 12px; color: var(--cream-3); text-align: right; }
.dist-bar { height: 14px; background: rgba(255,255,255,.06); border-radius: 1px; overflow: hidden; }
.dist-in { height: 100%; background: var(--gold); }
.dist-in.neg { background: var(--rose); }
.dist-in.flat { background: var(--line-2); }
.dist-v { font-family: "Golos", sans-serif; font-size: 12.5px; color: var(--cream-2); font-variant-numeric: lining-nums tabular-nums; }

/* ── разложение результата ───────────────────────────────────── */

.brk { display: grid; gap: 8px; }
.brk-row { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: var(--r-s); display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 18px; }
.brk-row.sum { background: var(--gold-soft); border-color: rgba(233,194,122,.3); }
.brk-k { font-size: 14.5px; color: var(--cream-2); }
.brk-row.sum .brk-k { color: var(--cream); font-weight: 500; }
.brk-v { font-family: var(--f-num), Georgia, serif; font-weight: 600; font-size: 17px; color: var(--gold); font-variant-numeric: lining-nums tabular-nums; }
.brk-v.neg { color: var(--rose); }

/* ── доля инструментов ───────────────────────────────────────── */

.syms { display: grid; gap: 12px; margin-top: 20px; }
.sym-row { display: grid; grid-template-columns: 52px 1fr 62px; align-items: center; gap: 12px; }
.sym-k { font-family: "Golos", sans-serif; font-size: 13px; }
.sym-bar { height: 14px; background: rgba(255,255,255,.06); border-radius: 1px; overflow: hidden; }
.sym-in { height: 100%; background: var(--gold); }
.sym-v { font-family: "Golos", sans-serif; font-size: 12.5px; color: var(--cream-2); text-align: right; font-variant-numeric: lining-nums tabular-nums; }

/* ── живая панель: кривая, дни, просадка и ползунок ──────────── */

.panel { display: grid; gap: 18px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; }

.panel-range { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; }
.panel-range button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--cream-3); font: 500 13px/1 "Golos", sans-serif;
  padding: 9px 14px; border-radius: 999px;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.panel-range button:hover { color: var(--cream); }
.panel-range button.on { background: var(--gold); color: var(--night); }

/* Числа периода крупные и сразу над графиком: они меняются вместе с ползунком,
   и читатель должен видеть связь без прокрутки. */
.panel-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pf {
  padding: 16px 18px; border-radius: var(--r-m);
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
}
.pf-n {
  display: block; font-family: var(--f-num), Georgia, serif; font-weight: 600; font-size: clamp(22px, 2.5vw, 30px);
  line-height: 1; color: var(--gold); font-variant-numeric: lining-nums tabular-nums;
}
.pf.neg .pf-n { color: var(--rose); }
.pf-k { display: block; margin-top: 9px; font-size: 12.5px; color: var(--cream-3); line-height: 1.35; }

.panel-chart { width: 100%; }

.g-bar { fill: var(--gold); opacity: .8; }
.g-bar.neg { fill: var(--rose); opacity: .85; }

.panel-slider { width: 100%; cursor: ew-resize; touch-action: none; user-select: none; }
.panel-slider svg { display: block; width: 100%; height: auto; }
.sl-line { fill: none; stroke: var(--cream-3); stroke-width: 1; opacity: .55; }
.sl-mask { fill: var(--night); opacity: .62; }
.sl-win { fill: var(--gold); opacity: .08; stroke: var(--gold); stroke-opacity: .35; }
.sl-grip { stroke: var(--gold); stroke-width: 1; }
.sl-knob { fill: var(--gold); cursor: ew-resize; }

.panel-hint { color: var(--cream-3); font-size: 13px; line-height: 1.6; max-width: 76ch; }

@media (max-width: 860px) {
  .panel-figs { grid-template-columns: 1fr 1fr; }
  .panel-head { align-items: flex-start; }
  .panel-range button { padding: 8px 11px; font-size: 12.5px; }
}

/* Недели без сделок: штриховка, а не заливка, чтобы не спорить с кривой. */
.g-quiet { fill: var(--line); opacity: .55; }

/* ── результат по периодам ───────────────────────────────────── */

.tranche { width: 100%; border-collapse: collapse; font-variant-numeric: lining-nums tabular-nums; }
.tranche th, .tranche td { padding: 15px 16px; text-align: right; border-bottom: 1px solid var(--line); }
.tranche th { font: 500 12px/1.3 "Golos", sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--cream-3); }
.tranche th:first-child, .tranche td:first-child { text-align: left; }
.tranche td { font-family: var(--f-num), Georgia, serif; font-weight: 600; font-size: 20px; color: var(--cream); }
.tranche td:first-child { font-family: "Golos", sans-serif; font-weight: 500; font-size: 15px; color: var(--cream-2); }
.tranche td.pos { color: var(--gold); }
.tranche td.neg { color: var(--rose); }
.tranche tr:last-child td { border-bottom: 0; }
.tranche tbody tr { transition: background var(--t) var(--ease); }
.tranche tbody tr:hover { background: var(--gold-soft); }
.tranche-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); }

.quiet-note { display: flex; gap: 14px; align-items: flex-start; color: var(--cream-2); font-size: 14.5px; line-height: 1.65; max-width: 80ch; }
.quiet-swatch { flex: 0 0 auto; width: 26px; height: 14px; margin-top: 4px; border-radius: 2px; background: var(--line); opacity: .9; }

@media (max-width: 640px) {
  .tranche th, .tranche td { padding: 11px 5px; }
  .tranche td { font-size: 15px; }
  .tranche thead th { font-size: 9.5px; letter-spacing: .04em; vertical-align: bottom; }
  .tranche tbody th { font-size: 13px; padding: 11px 6px 11px 10px; }
  .tranche td:last-child, .tranche th:last-child { padding-right: 10px; }
}
/* на узком телефоне пять колонок не помещаются: Кальмар и его пояснение уходят,
   а худшая просадка остаётся на экране, она важнее */
@media (max-width: 480px) {
  .tranche th:nth-child(5), .tranche td:nth-child(5) { display: none; }
  .tranche td:nth-child(4), .tranche th:nth-child(4) { padding-right: 10px; }
  .tranche-wrap + .note { display: none; }
}
@media (max-width: 380px) {
  .tranche th, .tranche td { padding-left: 3px; padding-right: 3px; }
  .tranche td { font-size: 14px; }
  .tranche tbody th { padding-left: 8px; font-size: 12.5px; }
}
.tranche tbody th { text-align: left; font: 500 15px/1.3 "Golos", sans-serif; letter-spacing: 0; text-transform: none; color: var(--cream-2); padding: 15px 16px; border-bottom: 1px solid var(--line); }
.tranche tbody tr:last-child th { border-bottom: 0; }
.tranche tbody tr:last-child th, .tranche tbody tr:last-child td { font-weight: 700; }
