/* trend analysis: 8 series colours (fixed per series, graded separately for light/dark) */
:root { --tr-s1: #2a78d6; --tr-s2: #eb6834; --tr-s3: #1baf7a; --tr-s4: #eda100; --tr-s5: #e87ba4; --tr-s6: #008300; --tr-s7: #4a3aa7; --tr-s8: #e34948; }
:root[data-theme="dark"] { --tr-s1: #3987e5; --tr-s2: #d95926; --tr-s3: #199e70; --tr-s4: #c98500; --tr-s5: #d55181; --tr-s6: #008300; --tr-s7: #9085e9; --tr-s8: #e66767; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --tr-s1: #3987e5; --tr-s2: #d95926; --tr-s3: #199e70; --tr-s4: #c98500; --tr-s5: #d55181; --tr-s6: #008300; --tr-s7: #9085e9; --tr-s8: #e66767; }
}
/* Settings at the top: layout as in all views (style.css .cfg-card, quick selection .seg); here only what trends needs specifically */
.tr-span { display: inline-flex; flex-wrap: wrap; gap: 8px 18px; }  /* From and To wrap together */
.tr-live { margin-inline-start: auto; }
@media (max-width: 700px) { .tr-live { margin-inline-start: 0; } }
.tr-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .tr-layout { grid-template-columns: 1fr; } }
.tr-selection { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
/* Row «Filter» at the top: search and selections are side by side like the other fields of the row */
.tr-filter input[type=search] { width: min(240px, 100%); }
.tr-vals-filter { display: contents; }
.tr-group-head { display: flex; width: 100%; align-items: center; gap: 6px; background: none; border: 0; border-radius: 6px; font: inherit; cursor: pointer; text-align: start;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--ink-2); margin: 8px 0 1px; padding: 3px 4px; }
.tr-group-head:hover:not(:disabled) { background: var(--card-2); color: var(--ink); }
.tr-group-head:disabled { cursor: default; }
.tr-group-head::before { content: "▸"; font-size: 10px; transition: transform .15s; }
.tr-group.opened > .tr-group-head::before { transform: rotate(90deg); }
.tr-group-head > span:first-child { flex: 1; min-width: 0; }
.tr-under { margin-inline-start: 12px; }
.tr-under > .tr-group-head { margin-top: 4px; font-size: 12px; text-transform: none; letter-spacing: 0; }  /* Group: name as written, so area and group stand out */
.tr-count { font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.tr-series { display: flex; align-items: center; gap: 6px; padding: 1px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1.35; }
.tr-series:hover { background: var(--card-2); }
.tr-series.inactive .tr-name { color: var(--muted); }
.tr-series .tr-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* full name in the tooltip (title) */
.tr-color { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; flex: none; }
.tr-color.pattern { width: 24px; }
.tr-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-bottom: 4px; }
.tr-leg { display: inline-flex; align-items: center; gap: 6px; }
.tr-chart.loading { opacity: .55; }
.tr-empty { text-align: center; padding: 60px 0; }
svg.trend { width: 100%; height: auto; display: block; margin: 6px 0; user-select: none; cursor: crosshair; }
svg.trend .grid { stroke: var(--line); stroke-width: 1; }
svg.trend .axis_line { stroke: var(--axis); stroke-width: 1; }
svg.trend .axis { fill: var(--muted); font-size: 11px; }
svg.trend .axis.title { fill: var(--ink-2); font-weight: 600; }
svg.trend .axis_color { stroke-width: 3; stroke-linecap: round; }
svg.trend .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.trend .band { opacity: .15; stroke: none; }
svg.trend .limit_value { stroke-width: 1; stroke-dasharray: 4 4; opacity: .8; }
svg.trend .limit_value.hard { stroke-width: 1.5; stroke-dasharray: none; }  /* LL/HH */
svg.trend .cross { stroke: var(--axis); stroke-width: 1; }
svg.trend .point { stroke: var(--card); stroke-width: 2; }
svg.trend .wick { stroke-width: 1; }
svg.trend .candle { stroke-width: 1; }
svg.trend .selection { fill: var(--accent); opacity: .12; }
.tr-r.stark { font-weight: 600; }
.tr-corr.short table.data th, .tr-corr.short table.data td { padding-inline: 5px; }
.tr-corr.short table.data td:first-child { white-space: nowrap; }
/* Printout (A4 landscape; from 5 stacked charts portrait): only chart with legend, statistics and correlation – value list, time selection and zoom hint are dropped (the period is in the print header).
   Series colours always light; the additions make the rule as specific as the dark colours above. */
@media print {
  :root, :root[data-theme], :root:not([data-theme="light"]) { --tr-s1: #2a78d6; --tr-s2: #eb6834; --tr-s3: #1baf7a; --tr-s4: #eda100; --tr-s5: #e87ba4; --tr-s6: #008300; --tr-s7: #4a3aa7; --tr-s8: #e34948; }
  .tr-filter, .tr-selection, .tr-zoom-tip, .tr-legend .link-x, svg.trend .cross, svg.trend .point, svg.trend .selection { display: none !important; }
  .tr-layout { display: block; }
  .tr-chart { opacity: 1; break-inside: avoid; }
  .tr-right .card { break-inside: avoid; }
  svg.trend { max-height: 132mm; }  /* chart including legend stays on the first page */
  svg.trend.high { max-height: 212mm; }
  /* Tables stay on the page: without sort arrows, narrower cells, column headers with series names may wrap */
  .tr-stat table.data th.sortable .th-in::after, .tr-corr table.data th.sortable .th-in::after { content: none; }
  .tr-stat table.data th, .tr-stat table.data td, .tr-corr table.data th, .tr-corr table.data td { padding-inline: 5px; }
  .tr-corr.short table.data th, .tr-corr.short table.data td { padding-inline: 3px; }
  .tr-corr table.data th { white-space: normal; }
}
