/* Графики: оси, столбцы, линии, пончик, теплокарта, легенда и подсказка.
   Всё рисуется движком из js/charts.js — здесь только внешний вид. */

.chart-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.chart-box {
  position: relative; width: 100%; min-width: 0;
  /* Наведение работает по всей площади, но вертикальная прокрутка страницы
     на телефоне остаётся: касание графика не должно «залипать». */
  touch-action: pan-y;
  outline: none; border-radius: 10px;
}
.chart-box:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 1px var(--accent); }
.chart-box > svg.ch { display: block; overflow: visible; }

/* ---------- Оси и сетка ---------- */
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-grid.zero { stroke: color-mix(in srgb, var(--text-3) 55%, transparent); }
.ch-tick {
  font-size: 9.5px; font-weight: 600; font-family: var(--font-num);
  fill: var(--text-3); opacity: 0.85; letter-spacing: 0.01em;
}
.ch-xtick { text-anchor: middle; font-size: 10px; }
/* Подписи вертикальной оси прижаты к правому краю левого поля. */
.ch-ytick { text-anchor: end; }

/* ---------- Столбцы ---------- */
.ch-plot { transform-box: view-box; }
.ch-bar { transition: opacity 140ms var(--ease); }
.ch-bar.faded { opacity: 0.32; }
.ch-band { fill: var(--fill); opacity: 0.75; }

/* ---------- Линии и области ---------- */
.ch-line { transition: opacity 140ms var(--ease); }
.ch-line.dashed { stroke-dasharray: 5 5; opacity: 0.85; }
.ch-area { pointer-events: none; }
.ch-cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.7; }
.ch-dot { stroke: var(--surface); stroke-width: 2; filter: drop-shadow(0 1px 3px rgba(8, 10, 16, 0.35)); }

/* ---------- Пончик ---------- */
.chart-donut .chart-box { display: grid; place-items: center; }
.ch-donut { position: relative; }
.ch-arc {
  transform-box: view-box;
  transition: opacity 140ms var(--ease), transform 160ms var(--ease);
  cursor: pointer;
}
.ch-arc.faded { opacity: 0.38; }
.ch-arc.on { transform: scale(1.04); }
.ch-donut-center {
  position: absolute; inset: 22%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; text-align: center; pointer-events: none;
}
.ch-donut-value {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: 18px; font-weight: 720; letter-spacing: -0.03em; line-height: 1.05;
}
.ch-donut-label {
  font-size: 10.5px; font-weight: 600; color: var(--text-3); line-height: 1.2;
  max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ---------- Теплокарта ---------- */
.ch-cell { transition: opacity 140ms var(--ease); }
.ch-cell-on { fill: none; stroke: var(--text); stroke-width: 1.4; opacity: 0.55; }
.ch-cell-day {
  text-anchor: middle; font-size: 10.5px; font-weight: 600; font-family: var(--font-num);
  fill: var(--text-2); pointer-events: none;
}
/* На густо залитой клетке номер дня читается только светлым. */
.ch-cell-day.over { fill: #fff; opacity: 0.92; }

/* ---------- Легенда: клик выключает ряд ---------- */
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.ch-legend-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--glass-soft); border: 1px solid var(--glass-edge);
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ch-legend-item:hover { color: var(--text); }
.ch-legend-item.off { opacity: 0.45; text-decoration: line-through; }
.ch-legend-item i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.ch-legend-item i.dash { height: 0; border-top: 2px dashed currentColor; width: 12px; border-radius: 0; background: none; }

.ch-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.ch-foot b { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 650; }

/* ---------- Подсказка ---------- */
.ch-tip {
  position: fixed; z-index: 150; left: 0; top: 0; pointer-events: none;
  min-width: 132px; max-width: 260px; padding: 9px 11px; border-radius: 13px;
  background: var(--sheet-bg);
  backdrop-filter: var(--sheet-blur); -webkit-backdrop-filter: var(--sheet-blur);
  border: 1px solid var(--sheet-edge);
  box-shadow: 0 10px 30px -12px rgba(8, 10, 16, 0.5);
  opacity: 0; transform: translateY(3px);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}
.ch-tip.on { opacity: 1; transform: none; }
.ch-tip-head { font-size: 12px; font-weight: 700; margin-bottom: 5px; color: var(--text); }
.ch-tip-row { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; color: var(--text-2); padding: 1px 0; }
.ch-tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; transform: translateY(-1px); }
.ch-tip-row span { flex: 1; min-width: 0; }
.ch-tip-row b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text); white-space: nowrap; }
.ch-tip-row.dim, .ch-tip-row.dim b { color: var(--text-3); font-weight: 600; }
.ch-tip-row.total { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--line); }

/* ---------- Появление ---------- */
.ch-grow { animation: ch-grow 520ms var(--ease) both; }
@keyframes ch-grow { from { transform: scaleY(0.02); opacity: 0; } }

.ch-spin { animation: ch-spin 620ms var(--ease) both; }
@keyframes ch-spin { from { transform: rotate(-16deg) scale(0.92); opacity: 0; } }

.ch-line.ch-draw { stroke-dasharray: 3000; animation: ch-draw 760ms var(--ease) both; }
@keyframes ch-draw { from { stroke-dashoffset: 3000; } to { stroke-dashoffset: 0; } }
/* Пунктир рисуем без «проявления»: там штриховка занята узором. */
.ch-line.dashed.ch-draw { stroke-dasharray: 5 5; animation: ch-fade 520ms var(--ease) both; }
@keyframes ch-fade { from { opacity: 0; } to { opacity: 0.85; } }

/* ---------- Переключатель вида графика ---------- */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-modes { display: inline-flex; gap: 2px; padding: 2px; border-radius: 11px; background: var(--fill); }
.chart-modes button {
  height: 28px; padding: 0 11px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--text-3);
  transition: all var(--dur) var(--ease);
}
.chart-modes button:hover { color: var(--text); }
.chart-modes button.active { background: var(--segment-active); color: var(--text); box-shadow: var(--segment-shadow); }

@media (max-width: 700px) {
  .ch-donut-value { font-size: 16px; }
  .chart-modes button { padding: 0 9px; font-size: 12px; }
}
