/* The chart module (charts.mjs). Colours only from tokens in design.css (light and dark);
   thin marks, hairline grid, one axis, the data is the only loud thing. */
.ch-chart { --ch-surface: var(--legacy-surface); margin: 0; min-width: 0; container-type: inline-size; }
.ch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ch-s1 { background: var(--chart-1); } .ch-s2 { background: var(--chart-2); }
.ch-s3 { background: var(--chart-3); } .ch-s4 { background: var(--chart-4); }
.ch-s5 { background: var(--chart-5); } .ch-s6 { background: var(--chart-6); }
.ch-s7 { background: var(--chart-7); } .ch-s8 { background: var(--chart-8); }
.ch-neutral { background: var(--legacy-line-strong); }

.ch-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); list-style: none; margin: var(--space-1) 0 var(--space-3); padding: 0; font-size: var(--text-small); color: var(--legacy-ink-soft); }
.ch-legend li { display: inline-flex; align-items: center; gap: var(--space-2); }
.ch-legend strong { color: var(--legacy-ink); font-variant-numeric: tabular-nums; }
.ch-sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Bar and area chart: y ticks in a 64px band on the left, dashed hairline grid. */
.ch-plot { position: relative; padding-left: var(--space-16); }
.ch-plot.ch-has-note { padding-top: var(--space-6); }
.ch-area { position: relative; }
.ch-grid, .ch-cols { position: absolute; inset: 0; }
.ch-gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--legacy-line); }
.ch-baseline { border-top: 1px solid var(--legacy-line-strong); }
.ch-tick { position: absolute; right: calc(100% + 8px); transform: translateY(-50%); font-size: var(--text-label); color: var(--legacy-ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; word-spacing: normal; }
.ch-cols { display: grid; }
.ch-col { position: relative; display: flex; justify-content: center; gap: 2px; padding: 0 12%; border-radius: var(--radius-sm); cursor: default; }
.ch-col:hover, .ch-col:focus-visible { background: color-mix(in srgb, var(--legacy-ink) 5%, transparent); }
.ch-slot { position: relative; flex: 0 1 14px; min-width: 3px; }
.ch-bar { position: absolute; left: 0; right: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ch-bar.ch-down { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ch-stacked .ch-bar { border-radius: 0; box-sizing: border-box; }
.ch-stacked .ch-bar + .ch-bar { border-bottom: 2px solid var(--ch-surface); }
.ch-stacked .ch-bar.ch-top { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ch-note { position: absolute; left: 50%; transform: translate(-50%, -4px); font-size: var(--text-label); font-weight: 600; color: var(--legacy-ink); white-space: nowrap; }
.ch-note-end { left: auto; right: 12%; transform: translateY(-4px); }
.ch-xaxis { display: grid; margin-top: var(--space-2); font-size: var(--text-label); color: var(--legacy-ink-soft); font-variant-numeric: tabular-nums; word-spacing: normal; }
.ch-xaxis span { text-align: center; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* tenant-17: every second month hidden, the shown ones use the free room instead of "0…" */
@container (max-width: 480px) { .ch-xaxis.ch-dense span:nth-child(even) { visibility: hidden; } .ch-xaxis.ch-dense span { overflow: visible; text-overflow: clip; } }

/* Area chart: soft fill from the series colour, dashed crosshair, one dot per series. */
.ch-area-plot { outline-offset: 4px; }
.ch-area-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ch-area-line { fill: none; stroke-width: 2.25; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ch-ls1 { stroke: var(--chart-1); } .ch-ls2 { stroke: var(--chart-2); } .ch-ls3 { stroke: var(--chart-3); } .ch-ls4 { stroke: var(--chart-4); }
.ch-gs1 stop { stop-color: var(--chart-1); } .ch-gs2 stop { stop-color: var(--chart-2); } .ch-gs3 stop { stop-color: var(--chart-3); } .ch-gs4 stop { stop-color: var(--chart-4); }
.ch-stop-top { stop-opacity: 0.28; } .ch-stop-bottom { stop-opacity: 0; }
.ch-cross { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px dashed var(--legacy-ink-soft); pointer-events: none; }
.ch-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; box-shadow: 0 0 0 3px var(--ch-surface), 0 2px 6px rgb(16 18 34 / 20%); pointer-events: none; }
.ch-xaxis-area { position: relative; height: 18px; margin-top: var(--space-2); font-size: var(--text-label); color: var(--legacy-ink-soft); word-spacing: normal; }
.ch-xaxis-area span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ch-xaxis-area .ch-first { transform: none; } .ch-xaxis-area .ch-last { transform: translateX(-100%); }
@container (max-width: 520px) { .ch-xaxis-area span:nth-child(even):not(.ch-last), .ch-xaxis-area span:nth-last-child(2) { display: none; } }

/* Tooltip: values lead, the series follows behind a short line key. */
.ch-tip { position: absolute; z-index: 5; transform: translate(-50%, -12px); background: var(--legacy-surface); color: var(--legacy-ink); border: 1px solid var(--legacy-line); border-radius: var(--radius-md); box-shadow: var(--legacy-shadow-lg); padding: var(--space-2) var(--space-3); font-size: var(--text-small); white-space: nowrap; pointer-events: none; }
.ch-tip-start { transform: translate(-24px, -12px); }
.ch-tip-end { transform: translate(calc(-100% + 24px), -12px); }
.ch-tip-head { color: var(--legacy-ink-soft); margin-bottom: 2px; }
.ch-tip-row { display: flex; align-items: center; gap: var(--space-2); }
.ch-tip-row strong { color: var(--legacy-blue); font-variant-numeric: tabular-nums; }
.ch-key { display: inline-block; width: 12px; height: 2px; border-radius: var(--radius-full); }

.ch-table-view { margin-top: var(--space-3); }
.ch-table-view summary { list-style: none; display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; font-size: var(--text-small); font-weight: 600; color: var(--legacy-blue); }
.ch-table-view summary::-webkit-details-marker { display: none; }
.ch-table-view summary::after, .ch-action::after { content: ""; display: inline-block; flex: none; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--icon-pfeil, linear-gradient(transparent, transparent)) center / contain no-repeat; mask: var(--icon-pfeil, linear-gradient(transparent, transparent)) center / contain no-repeat; }
.ch-table-view summary:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Headline figure: label and date on top, the number, the change as a pill "ggü. …", the
   sparkline, the action; a tinted symbol top right. */
.ch-figure { position: relative; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label badge" "period badge" "value value" "trend trend" "spark spark" "action action"; align-content: start; }
.ch-figure p { margin: 0; }
.ch-label { grid-area: label; font-size: var(--text-body); font-weight: 600; color: var(--ink-2); }
.ch-period { grid-area: period; margin-top: 2px; font-size: var(--text-small); color: var(--legacy-ink-soft); }
.ch-badge { grid-area: badge; align-self: start; display: grid; place-items: center; width: 40px; height: 40px; margin-left: var(--space-3); border-radius: 50%; }
.ch-badge .wf-icon { width: 20px; height: 20px; stroke-width: 2; }
/* A symbol is no state (designer-r2-13): violet for a figure, lime only for the Autopilot's (brand). */
.ch-tint-violet { background: var(--legacy-blue-soft); color: var(--legacy-blue); }
.ch-tint-auto { background: var(--lime); color: var(--on-lime); }
.ch-value { grid-area: value; margin: var(--space-4) 0 var(--space-2) !important; font-size: var(--text-figure); font-weight: 700; font-stretch: var(--font-display-stretch); line-height: 1.1; letter-spacing: -0.025em; word-spacing: normal; font-variant-numeric: tabular-nums; color: var(--legacy-ink); }
.ch-trendline { grid-area: trend; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: var(--text-small); color: var(--legacy-ink-soft); }
.ch-delta { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 var(--space-2); border-radius: var(--radius-full); font-size: var(--text-small); font-weight: 700; background: var(--sunken); color: var(--ink-2); font-variant-numeric: tabular-nums; word-spacing: normal; white-space: nowrap; }
.ch-delta.ch-good { background: var(--legacy-success-soft); color: var(--legacy-success); }
.ch-delta.ch-bad { background: var(--legacy-danger-soft); color: var(--legacy-danger); }
.ch-good { color: var(--legacy-success); } .ch-bad { color: var(--legacy-danger); }
.ch-action { grid-area: action; display: inline-flex; gap: var(--space-1); justify-self: start; margin-top: var(--space-4); font-size: var(--text-small); }
.ch-figure .ch-spark { grid-area: spark; display: block; margin-top: var(--space-4); }

.ch-spark { width: 120px; height: 36px; vertical-align: middle; overflow: visible; }
.ch-spark .ch-spark-line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ch-spark .ch-spark-fill { fill: var(--chart-1); fill-opacity: 0.12; stroke: none; }
.ch-spark circle { fill: var(--chart-1); stroke: var(--ch-surface, var(--legacy-surface)); stroke-width: 2; }

/* Bar list: name, a light bar from zero with its figure in dark ink (AA on the bar). */
.ch-barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.ch-barlist-row { display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); gap: var(--space-3); align-items: center; font-size: var(--text-body); }
.ch-barlist-label { overflow-wrap: anywhere; }
.wf-body .ch-barlist-label a { color: var(--legacy-ink); font-weight: 500; }
.wf-body .ch-barlist-label a:hover { color: var(--legacy-blue); }
.ch-barlist-track { display: flex; align-items: center; gap: var(--space-2); border-radius: var(--radius-sm); background: var(--sunken); }
.ch-barlist-bar { display: flex; justify-content: flex-end; align-items: center; min-width: 2.5rem; height: 28px; box-sizing: border-box; padding: 0 var(--space-3); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--chart-1) 28%, var(--legacy-surface)); }
.ch-barlist-bar.ch-s2 { background: color-mix(in srgb, var(--chart-2) 28%, var(--legacy-surface)); }
.ch-barlist-value { color: var(--bar-ink); font-size: var(--text-small); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; word-spacing: normal; }
.ch-barlist-bar.ch-s2 .ch-barlist-value { color: var(--bar-ink-2); }
.ch-barlist-value.ch-barlist-out { color: var(--legacy-ink); }

/* Progress bar */
.ch-progress { display: grid; gap: var(--space-2); }
.ch-progress-head { display: flex; justify-content: space-between; gap: var(--space-3); margin: 0; font-size: var(--text-body); font-weight: 500; }
.ch-progress-head strong { font-variant-numeric: tabular-nums; }
.ch-progress-track { height: 10px; border-radius: var(--radius-full); background: var(--sunken); overflow: hidden; }
.ch-progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.ch-result-bar { display: flex; gap: 3px; height: 14px; border-radius: var(--radius-full); overflow: hidden; }
.ch-seg { display: block; min-width: 2px; }
.ch-result .ch-legend { margin-top: var(--space-2); }

/* Status: symbol + word as a soft pill; the symbol carries the status colour. */
.ch-state { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 24px; box-sizing: border-box; padding: 2px var(--space-3) 2px var(--space-2); border-radius: var(--radius-full); font-size: var(--text-tag); font-weight: 600; line-height: 1.35; letter-spacing: 0.04em; text-transform: uppercase; word-spacing: normal; background: var(--legacy-success-soft); color: var(--legacy-success); }
.ch-state-warn { background: var(--legacy-warning-soft); color: var(--legacy-warning); }
.ch-state-crit { background: var(--legacy-danger-soft); color: var(--legacy-danger); }
.ch-state svg { flex: none; }
.ch-table .ch-state { white-space: nowrap; } /* a state in a table cell stays one pill */
.ch-state-ok svg { fill: var(--status-good); }
.ch-state-warn svg { fill: var(--status-warning); }
.ch-state-crit svg { fill: var(--status-critical); }
.ch-state .ch-glyph { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-state-warn .ch-glyph { stroke: #232323; }

/* Money table: text left, figures right in tabular figures, negatives with minus sign and colour. */
.ch-table-wrap { overflow-x: auto; max-width: 100%; position: relative; } /* keeps a hidden cell label (.zs-area) inside the scroller: no sideways page scroll */
.ch-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--text-body); color: var(--legacy-ink); }
.ch-table th, .ch-table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--legacy-line); vertical-align: top; overflow-wrap: break-word; }
.ch-table thead th { padding: var(--space-3) var(--space-4); background: var(--sunken); color: var(--legacy-ink-soft); font-size: var(--text-small); font-weight: 600; white-space: nowrap; }
.ch-table thead th:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.ch-table thead th:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.ch-table tbody th { font-weight: 500; }
.ch-table tbody tr:hover > * { background: var(--hover); }
.ch-table .ch-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-table .ch-nowrap { white-space: nowrap; }
/* a cell of several lines (stored value, chip, note) that wraps inside its column and on a phone */
.ch-table .ch-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); min-width: 0; }
.ch-table .ch-wrap > * { max-width: 100%; white-space: normal; }
.ch-table .ch-wrap > .wf-muted { overflow-wrap: anywhere; }
.ch-table .ch-neg { color: var(--legacy-danger); }
.ch-table .ch-muted > * { color: var(--legacy-ink-soft); }
.ch-table .ch-sum > * { font-weight: 700; border-top: 1px solid var(--legacy-line-strong); border-bottom: 0; }

@media (max-width: 767px) {
  .ch-figure .ch-value { font-size: var(--text-title); margin: var(--space-3) 0 var(--space-2) !important; }
  .ch-chart:has(.ch-cols) { overflow-x: auto; padding-top: var(--space-3); padding-left: var(--space-16); }
  .ch-plot:has(.ch-cols) { box-sizing: border-box; min-width: calc(var(--ch-count) * 44px); padding-left: 0; }
  .ch-barlist-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .ch-legend, .ch-trendline, .ch-period, .ch-label, .ch-tick, .ch-xaxis, .ch-xaxis-area, .ch-tip, .ch-table thead th, .ch-barlist-value, .ch-note, .ch-action, .ch-table-view summary, .ch-state, .ch-delta { font-size: var(--text-small); }
  .ch-tick { font-size: var(--text-label); }
  .ch-delta { height: 28px; }
  .ch-state { min-height: 28px; }
  .ch-action, .ch-table-view summary { min-height: 44px; }
  .ch-table-wrap { margin: 0 -16px; padding: 0 var(--space-4); }
  .ch-table th, .ch-table td { white-space: nowrap; }
  .ch-table tbody th, .ch-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--legacy-surface); }
}

@media (max-width: 600px) {
  .ch-table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  .ch-table, .ch-table tbody, .ch-table tr { display: block; width: 100%; }
  .ch-table thead { display: none; }
  .ch-table tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--legacy-line); }
  .ch-table tbody th, .ch-table td { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; border: 0; white-space: normal; position: static; text-align: left; }
  .ch-table tbody th { font-weight: 600; }
  .ch-table td[data-label]::before { content: attr(data-label); color: var(--legacy-ink-soft); font-weight: 400; }
  .ch-table td:empty { display: none; }
  .ch-table .ch-num { text-align: right; }
  .ch-table tbody tr:hover > * { background: none; }
}

@media (forced-colors: active) {
  .ch-bar, .ch-seg, .ch-sw, .ch-key, .ch-barlist-bar, .ch-progress-fill, .ch-dot { background: CanvasText; }
  .ch-state svg { fill: CanvasText; }
  .ch-area-line { stroke: CanvasText; }
}
