/* =========================================================================
   Графики Sfera (docs/web/ux.md, «Графики»; ChartHelper, chart_tip_controller.js).
   Две раскладки одного графика — широкая (viewBox 720) и узкая (360):
   шрифт SVG масштабируется вместе с viewBox, и подписи 10,5 единиц на
   телефоне сжимались до 4–5 px. Раскладку выбирает container query по
   ширине самого графика, а не окна: панель в сетке бывает узкой и на
   десктопе. Цвета — только токены --chart-*.
   ========================================================================= */
.chart { container-type: inline-size; }
.chart-plot { position: relative; touch-action: pan-y; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.hourly-chart { width: 100%; height: auto; display: block; color: var(--text); overflow: visible; }
.chart-narrow { display: none; }
@container (max-width: 560px) {
  .chart-wide { display: none; }
  .chart-narrow { display: block; }
}
.chart-tick { font-size: 11px; fill: var(--text-muted); font-variant-numeric: var(--nums); }
.chart-axis-label { font-size: 11px; fill: var(--text-muted); }
/* узкий viewBox 360 на 300–560 px контейнера: 14 единиц = 11,7–21 px */
.chart-narrow .chart-tick, .chart-narrow .chart-axis-label { font-size: 14px; }
.chart-cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart-hit { cursor: crosshair; }
.chart-legend { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); margin: 6px 0 8px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { flex: none; overflow: visible; }
/* строка значений (aria-live): без выбранной колонки — только для
   скринридера (подсказка «наведіть…» над каждым графиком была шумом,
   AUDIT №427; как пользоваться — в справке); с колонкой — плашка поверх
   верха области графика (`.chart-stage`, `.uic-body`), а не шапки: легенда
   остаётся видна (№436); места в потоке не занимает, график не прыгает. */
.chart-stage, .uic-body { position: relative; }
.chart-readout {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0; margin: 0; padding: 6px 10px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-elevated); box-shadow: var(--shadow-sm);
  font-size: 13px; line-height: 1.45; color: var(--text); font-variant-numeric: var(--nums); pointer-events: none;
}
.chart-readout:not(.is-active) {
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; box-shadow: none;
}
.chart-readout b { font-weight: 600; }
/* форма выбора ревизии в шапке графика прогона: select в label-колонке
   растягивался по высоте от flex: 1 1 260px */
#hourly-chart .panel-head form label > select { flex: 0 0 auto; }

/* --- набор графиков каркаса (UiChartsHelper, AUDIT №394) -------------------
   SVG — только геометрия (preserveAspectRatio="none", толщина не
   масштабируется), подписи — HTML поверх в процентах: шрифт не сжимается на
   телефоне. Узкий контейнер прячет второстепенные подписи оси X. */
.uic { container-type: inline-size; margin: 0; min-width: 0; }
.uic-cap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 22px; }  /* место под подписи значений над верхом области (плашка «35,0» — 21 px) */
.uic-unit { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.uic-legend { margin: 0; }
.uic-legend-title { color: var(--text-muted); }
.uic-capnote { font-size: 12px; color: var(--text-muted); }
.uic-body { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto 22px; column-gap: 8px; }
/* теплокарта: колонка дат — фиксированной ширины («21.10–28.10» свёрнутой строки
   и «20.10, вт.» влезают), подписи справа и не наезжают на ячейки */
.uic-heat .uic-body { grid-template-columns: 6.6em minmax(0, 1fr); }
.uic-heat .uic-y span { max-width: 100%; }
.uic-heat-note { position: absolute; left: 12px; right: 12px; transform: translateY(-50%); font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.uic-heat .uic-legend { flex-wrap: wrap; }
.uic-y { position: relative; font-size: 11px; color: var(--text-muted); font-variant-numeric: var(--nums); }
.uic-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.uic-plot { position: relative; height: var(--uic-h, 220px); }
.uic-heat .uic-plot { height: calc(var(--uic-rows, 7) * 22px); }
.uic-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.uic-x { position: relative; font-size: 11px; color: var(--text-muted); font-variant-numeric: var(--nums); }
.uic-x span { position: absolute; top: 5px; transform: translateX(-50%); white-space: nowrap; }
.uic-x span:not(.is-major) { visibility: hidden; }
.uic-xtitle, .uic-note { margin: 4px 0 0 52px; font-size: 12px; color: var(--text-muted); }
.uic-grid { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.uic-grid.is-dashed { stroke-dasharray: 3 3; }
.uic-zero { stroke: var(--text-muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.uic-line { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* точка — отрезок нулевой длины с круглым концом: не искажается при растяжении */
.uic-dot { stroke-width: 7; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.uic-dot.is-big { stroke-width: 12; }
.uic-tick { stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* «Моделі» (№455): зона «точніше й дешевше», выбранная точка, диапазон полосой */
.uic-zone { fill: var(--chart-s3); fill-opacity: 0.1; stroke: none; }
.uic-zone-label { position: absolute; left: 6px; bottom: 6px; font-size: 11.5px; color: var(--text-muted); pointer-events: none; }
a.uic-pnum.is-link { z-index: 3; text-decoration: none; cursor: pointer; pointer-events: auto; }
a.uic-pnum.is-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.uic-pnum.is-selected { box-shadow: 0 0 0 3px var(--bg-elevated), 0 0 0 5px var(--text); }
a.uic-pkey-name { color: var(--link); }
a.uic-pkey-name[aria-current="true"] { font-weight: 700; }
.uic-rangebar { position: relative; display: inline-block; width: 110px; height: 10px; vertical-align: middle; margin-left: 10px; }
.uic-rangebar::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 2px; border-radius: 1px; background: var(--chart-grid); }
.uic-rangebar-span { position: absolute; top: 2px; height: 6px; border-radius: 3px; background: var(--chart-s1); opacity: 0.45; }
.uic-rangebar-dot { position: absolute; top: 0; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--chart-s1); }
/* день недели под датой оси суток (ui_day_axis weekdays:, №455) */
.uic-x span .uic-wd { display: block; font-size: 10.5px; text-align: center; color: var(--text-faint); }
.uic:has(.uic-wd) .uic-body { grid-template-rows: auto 34px; }
/* составной график разбора доби: линии и отклонения на одной оси часов —
   у верхнего подписи часов скрыты, нижний ниже (№455) */
.uic-stack > .uic + .uic { margin-top: 6px; }
.uic-stack > .uic:first-child .uic-body { grid-template-rows: auto 4px; }
.uic-stack > .uic:first-child .uic-x { visibility: hidden; }
.uic-stack > .uic:last-child { --uic-h: 120px; --uic-h-narrow: 100px; }
.uic-range { stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.75; }
.uic-band { fill: var(--chart-band); fill-opacity: 0.18; stroke: none; }
.uic-bar.is-muted { fill: var(--chart-muted); }
.uic-bar.is-pending { fill: none; stroke: var(--chart-muted); stroke-width: 1.5; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.uic-break { fill: var(--bg-elevated); }
.uic-cell { stroke: none; }
.uic-cell.is-empty { fill: var(--bg-sunken); }
.chart-cell-cursor { fill: none; stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.uic .chart-cursor { vector-effect: non-scaling-stroke; }
.uic-vlabel {
  position: absolute; transform: translate(-50%, -4px); font-size: 11px; font-weight: 600; line-height: 1.2;
  color: var(--text); white-space: nowrap; pointer-events: none; font-variant-numeric: var(--nums);
}
.uic-vlabel.is-over { padding: 1px 5px; border-radius: 5px; background: var(--text); color: var(--bg-elevated); }
/* точки «похибка × ціна»: номер у точки, имя — в легенде под графиком (№434) */
.uic-pnum {
  position: absolute; z-index: 2; display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; border: 1.5px solid var(--pnum, var(--text-muted)); background: var(--bg-elevated);
  color: var(--text); font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: var(--nums); pointer-events: none;
  transform: translate(8px, calc(50% + var(--shift, 0) * 21px));
}
.uic-pnum.is-key { position: static; transform: none; flex: none; }
.uic-pkey { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px 18px; font-size: 13px; }
.uic-pkey li { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.uic-pkey-text { display: flex; flex-direction: column; min-width: 0; }
.uic-pkey-name { font-weight: 500; }
.uic-pkey-val { color: var(--text-muted); font-size: 12px; white-space: nowrap; font-variant-numeric: var(--nums); }
.uic-legend .uic-mark-swatch { position: relative; top: auto; bottom: auto; display: inline-block; width: 14px; height: 12px; border-radius: 2px; }
/* полосы-отметки на оси времени: штриховка + слово в легенде (не только
   цветом). «Відключення» лежит ПОВЕРХ столбцов тонкой штриховкой с плотной
   кромкой сверху: под столбцами заявки её не было видно (№428). Штриховка
   — линия 1 px через 7 px, светлая (решение владельца 28.10, №437): на
   «Прогнозі на місяць» сутки отключений идут подряд, и плотная штриховка
   забивала линии прогноза и факта. Подписи значений — выше полосы. */
.uic-mark { position: absolute; top: 0; bottom: 0; pointer-events: none; border-inline: 1px dashed var(--chart-muted); }
.uic-mark-outage {
  z-index: 1; border-inline: 1px dashed var(--chart-mark-outage-line); border-top: 2px solid var(--chart-mark-outage-edge);
  background: repeating-linear-gradient(135deg, var(--chart-mark-outage-line) 0 1px, transparent 1px 8px), var(--chart-mark-outage);
}
.uic-mark-dst { background: repeating-linear-gradient(45deg, var(--chart-mark-dst) 0 6px, transparent 6px 12px); border-color: var(--chart-s4); }
.uic-plot .uic-vlabel { z-index: 2; }
.uic-data { margin: 8px 0 0; }
.uic-data summary { cursor: pointer; font-size: 13px; color: var(--link); width: max-content; }
.uic-data .ui-table-wrap { margin-top: 8px; max-height: 320px; }
.uic-col-link { position: absolute; top: 0; bottom: 0; z-index: 2; border-radius: 6px; }
.uic-col-link:hover { background: color-mix(in srgb, var(--link) 8%, transparent); }
.uic-col-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.uic-col-link[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--link); }
.uic-bar.is-highlight { stroke: var(--text); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.uic-empty { display: flex; flex-wrap: wrap; gap: 6px; padding: 18px; border-radius: 12px; border: 1px dashed var(--border-strong); color: var(--text-muted); }
.uic-empty b { color: var(--text); }
.uic-spark { width: 100%; display: block; }
/* столбики плитки «Точність» (ui_spark_bars, №454): выше порога — тон внимания, аварийные — серые */
.uic-spark-bars { width: 100%; height: 64px; display: block; }
.uic-sbar { fill: var(--chart-s1); }
.uic-sbar.is-high { fill: var(--chart-s2); }
.uic-sbar.is-muted { fill: var(--chart-muted); opacity: 0.6; }
@container (max-width: 560px) {
  .uic-plot { height: var(--uic-h-narrow, 180px); }
  .uic-vlabel.is-stagger { transform: translate(-50%, calc(-100% - 6px)); }
  .uic:has(.uic-vlabel.is-stagger) .uic-cap { margin-bottom: 40px; }
  .uic-x span:not(.is-wide) { visibility: hidden; }
}
.uic .chart-hit { fill: transparent; }
