/* 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); the period is a drop-down of its own (quick choices, From and To) */
.tr-period-menu { min-width: 0; }
.tr-period-menu button.on { font-weight: 600; color: var(--accent); }
.tr-period-free { display: grid; gap: 6px; padding: 8px 10px 4px; margin-top: 5px; border-top: 1px solid var(--line); }
.tr-period-free label { display: grid; gap: 2px; font-size: 12px; color: var(--ink-2); }
/* The value list on the left and the charts on the right each scroll by themselves; trends.js sets the height of the layout to the window
   below the head (user 30 Oct «ganzer werte bereich nicht mit ansicht rechts mitscrollen. eigener bereich für scroll je») */
main:has(> .trends .tr-layout) { padding-bottom: 16px; }
.tr-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.tr-selection, .tr-right { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tr-selection { padding-top: 0; }
.tr-right { min-width: 0; padding-inline-end: 2px; }
@media (max-width: 900px) { .tr-layout { grid-template-columns: 1fr; } .tr-selection { max-height: 60vh; } .tr-right { overflow: visible; } }
/* the filter of the value list at its top («filter bei werte oben»), below the title; it stays there while the list scrolls (a filter, no title:
   titles scroll along, user 31 Oct «sticky titel wieder entfernen») */
.tr-selection > h3 { background: var(--card); margin: 0; padding: 14px 0 8px; }
/* one row: the search and beside it the drop-down with the filters nested in it (user 31 Oct «filter für werte 2 zeilen dropdown geschachtelt in einem») */
.tr-filterbox { display: flex; gap: 6px; align-items: center; padding-bottom: 8px; background: var(--card); position: sticky; top: 0; z-index: 2; }
.tr-filterbox > input { flex: 1; min-width: 0; box-sizing: border-box; }
.tr-vals-dd { flex: none; }
.tr-vals-dd > .btn.on { border-color: var(--accent); color: var(--accent); }
.tr-vals-filter:not([hidden]) { display: grid; gap: 6px; min-width: 220px; padding: 8px; }
.tr-vals-filter select { width: 100%; box-sizing: border-box; }
.tr-group-head { display: flex; width: 100%; align-items: center; gap: 6px; background: var(--card); border: 0; border-radius: 0; font: inherit; cursor: pointer; text-align: start;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--ink-2); margin: 0; padding: 11px 4px 4px; }
/* the space above a head and the indent of a group are inside the head, which spans the whole width */
.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 > .tr-group-head { padding: 7px 4px 4px 16px; font-size: 12px; text-transform: none; letter-spacing: 0; }  /* Group: name as written, so area and group stand out */
.tr-under .tr-series { padding-inline-start: 16px; }
.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; height: auto !important; }
  .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; }
}
