/* Monitoring charts (M18, operator request of 2026-11-06: « des couleurs différentes pour les graphes, pour donner un peu de chaleur »).
   The demo has no monitoring view of its own: these extend charts.css and the CPU chart (app.css .chart-box) with the same marks,
   grid, threshold and inverse tooltip. Metric families take one fixed hue each, validated for contrast and colour-vision separation
   in both themes and kept apart from the status colours; proposal in docs/design/charts-palette.md, pending its entry in DESIGN.md. */

:root, [data-theme="light"] {
  --m-cpu: #F06410;     /* Tangerine */
  --m-mem: #A276FB;     /* Lilac */
  --m-disk: #1CA3B9;    /* Lagoon */
  --m-netin: #177AEA;   /* Azure */
  --m-netout: #BD368C;  /* Raspberry */
  --m-load: #6B4FD1;    /* Indigo */
  --m-temp: #F35E9B;    /* Rose */
}
[data-theme="dark"] {
  --m-cpu: #E96715;
  --m-mem: #A36DF0;
  --m-disk: #19A4B7;
  --m-netin: #1F6DD8;
  --m-netout: #DE5BB4;
  --m-load: #6753CD;
  --m-temp: #C63170;
}
.m-cpu { --tone: var(--m-cpu); }
.m-mem { --tone: var(--m-mem); }
.m-disk { --tone: var(--m-disk); }
.m-netin { --tone: var(--m-netin); }
.m-netout { --tone: var(--m-netout); }
.m-load { --tone: var(--m-load); }
.m-temp { --tone: var(--m-temp); }
/* Lighter steps of a family for its second and third series (cache beside used memory). */
.sh1 { --tone-s: color-mix(in oklab, var(--tone) 58%, var(--surface)); }
.sh2 { --tone-s: color-mix(in oklab, var(--tone) 34%, var(--surface)); }

/* Time chart (TimeChart): the CPU chart's box, gridlines, axis and threshold, for any series. */
.tc { margin: 0; display: grid; gap: 8px; min-width: 0; }
.tc-box { position: relative; height: var(--tc-h, 180px); min-width: 0; touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tc-box.is-linked { cursor: pointer; }
.tc-box.is-panning { cursor: grabbing; }
.tc-box:focus-visible { outline-offset: 3.5px; }
/* The still plot and the moving overlay (crosshair, dots, brush) are two layers of the same box. */
.tc-box svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
.tc-over { pointer-events: none; }
.tc-brush { fill: color-mix(in oklab, var(--accent) 13%, transparent); stroke: var(--accent); stroke-width: 1; }
.tc-box .axis { font: 500 10.5px var(--font-ui); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.tc-box .gridline { stroke: var(--grid); stroke-width: 1; }
.tc-box .threshold { stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 5 4; }
.tc-box .thr-label { font: 600 10.5px var(--font-ui); fill: var(--ink-2); }
.tc-box .cross { stroke: var(--ink-3); stroke-width: 1; }
.tc-line { fill: none; stroke: var(--tone-s, var(--tone)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tc-line.dashed { stroke-dasharray: 5 4; stroke-linecap: butt; }
.tc-lone { fill: var(--tone-s, var(--tone)); }
.tc-stop0 { stop-color: var(--tone-s, var(--tone)); stop-opacity: 0.16; }
.tc-stop1 { stop-color: var(--tone-s, var(--tone)); stop-opacity: 0; }
.tc-stack { fill: var(--tone-s, var(--tone)); opacity: 0.3; }
.tc-band { fill: var(--tone-s, var(--tone)); opacity: 0.14; }
.tc-dot { fill: var(--tone-s, var(--tone)); stroke: var(--surface); stroke-width: 2; }
.tc-tip {
  position: absolute; top: 4px; z-index: 2; pointer-events: none;
  display: grid; grid-template-columns: 9px auto auto; align-items: center; column-gap: 7px; row-gap: 3px;
  padding: 7px 9px; border-radius: 7.5px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop);
  font-size: 11.5px; line-height: 1.35; white-space: nowrap; transform: translateX(12px);
}
.tc-tip.left { transform: translateX(calc(-100% - 12px)); }
.tc-tip.pinned { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.tc-pin { margin-left: 6px; font-size: 10px; font-weight: 600; opacity: 0.85; }
.tc-tip-time, .tc-tip-hint { grid-column: 1 / -1; }
.tc-tip-time { font-weight: 600; opacity: 0.78; }
.tc-tip-hint { padding-top: 2px; font-size: 10.5px; opacity: 0.75; }
/* Rows share the tooltip's columns: key, name, then values aligned on the right. */
.tc-tip-row { display: contents; }
.tc-tip-row .c-key { background: var(--tone-s, var(--tone)); }
.tc-tip-label { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.tc-tip-row b { margin-left: 10px; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.tc-tip-row small { grid-column: 2 / -1; margin-top: -3px; font-size: 10.5px; opacity: 0.72; font-variant-numeric: tabular-nums; }
.tc-tip-row.total .tc-tip-label { grid-column: 1 / 3; }
.tc-tip-row.total > * { padding-top: 3px; border-top: 1px solid color-mix(in oklab, var(--bg) 22%, transparent); }
/* Legend entries are toggles: a hidden series keeps its entry, hollow and faded. */
.tc-legend { gap: 4px 6px; }
.tc-key {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 7px; margin-left: -7px; border: 0; border-radius: 6px;
  background: none; font: inherit; color: inherit; cursor: pointer;
}
.tc-key + .tc-key { margin-left: 0; }
.tc-key:hover { background: var(--sunken); }
.tc-key b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tc-key .c-key { background: var(--tone-s, var(--tone)); }
.tc-key .c-key.dashed { background: repeating-linear-gradient(90deg, var(--tone-s, var(--tone)) 0 3px, transparent 3px 5px); }
.tc-key[aria-pressed="false"] { color: var(--ink-3); }
.tc-key[aria-pressed="false"] b { color: var(--ink-3); }
.tc-key[aria-pressed="false"] .c-key { background: none; box-shadow: inset 0 0 0 1.5px var(--tone-s, var(--tone)); }
.tc-measures { margin-top: 2px; }
.tc-table { overflow-x: auto; }
.tc-measures table { max-width: none; width: auto; min-width: 306px; }
.tc-measures td, .tc-measures th { white-space: nowrap; }
.tc-skel { height: var(--tc-h, 180px); display: grid; }
.tc-skel-plot { display: block; height: 100%; border-radius: 9px; }
/* While loading, the expected legend entries and samples line (TimeChart Series without points), a heatmap's rows and the scale
   key, and a bar list's rows keep their lines: a figure's place is a short skeleton on the text line. */
.skel.tc-skel-value { display: inline-block; width: 38px; height: 9px; vertical-align: middle; }
.theat-plot > .tc-skel-plot { border-radius: 4px; }
details.measures[inert] summary { cursor: default; }
.tc-state { min-height: var(--tc-h, 180px); display: grid; align-content: center; justify-items: center; }
.tc-retry { display: block; margin-top: 10px; }
.tc.is-compact { gap: 4px; }
/* Bands (operator, 2026-11-06): a shaded span where the machine sent nothing, a hatched one where the period could not be read.
   Their words sit in the band, over the plot but outside the chart image; only the retry button takes the pointer. */
.tc-frame { position: relative; min-width: 0; }
.tc-gap { fill: color-mix(in oklab, var(--ink-3) 10%, transparent); }
.tc-gap.is-missing { fill: color-mix(in oklab, var(--ink-3) 4%, transparent); }
.tc-hatch { stroke: color-mix(in oklab, var(--ink-3) 34%, transparent); stroke-width: 1.5; }
.tc-notes { position: absolute; inset: 0; pointer-events: none; }
.tc-note { position: absolute; display: grid; align-content: center; justify-items: center; gap: 2px; padding: 0 6px; overflow: hidden; text-align: center; font: 500 10.5px var(--font-ui); line-height: 1.35; color: var(--ink-3); }
.tc-note strong, .tc-note span { display: -webkit-box; max-width: 100%; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: break-word; }
.tc-note strong { font-weight: 600; color: var(--ink-2); }
.tc-note .btn { margin-top: 4px; pointer-events: auto; }
.tc-note strong, .tc-note span { padding: 0 3px; border-radius: 4px; background: color-mix(in oklab, var(--surface) 72%, transparent); }

/* Measured key figures (MetricKpis, MetricKpi): the KPI strip's cells, five a row, each with its family's key and sparkline. */
.kpis.mkpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 0; overflow: hidden; }
.mkpis > .kpi { border: 0; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.mkpi { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "label label" "value spark" "sub sub"; column-gap: 12px; align-items: end; }
.mkpi .kpi-label { grid-area: label; min-width: 0; }
.mkpi .kpi-label .c-key { flex: none; }
.mkpi .kpi-value { grid-area: value; }
.mkpi .kpi-sub { grid-area: sub; min-width: 0; }
.mkpi-spark { grid-area: spark; height: 28px; min-width: 0; }
.mkpi-spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mkpi-line { fill: none; stroke: var(--tone); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.mkpi-area { stroke: none; }

/* Time heatmap (TimeHeatmap): one row per item, cells on the family's ramp from Sunken to the full hue. */
.theat { margin: 0; display: grid; gap: 6px; min-width: 0; }
.theat-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; }
.theat-labels { display: grid; grid-auto-rows: var(--row-h); font: 500 10px/1 var(--font-data); color: var(--ink-3); text-align: right; }
.theat-labels span { display: flex; align-items: center; justify-content: flex-end; }
.theat-plot { position: relative; height: calc(var(--rows) * var(--row-h)); min-width: 0; border-radius: 4px; }
.theat-plot:focus-visible { outline-offset: 3px; }
.theat-plot svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.theat-plot rect { fill: color-mix(in oklab, var(--tone) var(--v), var(--sunken)); }
[data-theme="dark"] .theat-plot rect { fill: color-mix(in oklab, var(--tone) var(--v), var(--line)); }
.theat-plot rect.theat-focus { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.theat-plot .tc-tip { top: 0; transform: translate(12px, -50%); }
.theat-plot .tc-tip.left { transform: translate(calc(-100% - 12px), -50%); }
.theat-plot .tc-tip .c-key { background: var(--tone); }
.theat-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font: 500 10.5px var(--font-ui); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.theat-key { display: inline-flex; align-items: center; gap: 6px; }
.theat-key i { width: 64px; height: 7px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in oklab, var(--tone) 6%, var(--sunken)), var(--tone)); }

/* Range selector (RangeSelector): a period past what is kept stays visible, faded, and says why in its title. A zoom shows its
   window beside the periods, with a chip back to the chosen period. */
.range-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; max-width: 100%; }
.range-sel button:disabled { color: var(--ink-3); opacity: 0.55; cursor: not-allowed; }
.range-sel button:disabled:hover { color: var(--ink-3); }
.range-zoom { display: inline-flex; align-items: center; gap: 6px; height: 27px; padding: 0 4px 0 10px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.range-zoom button { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; }
.range-zoom button:hover { color: var(--ink); }
/* Custom period: the chip reopens the dialog, its round × goes back to the preset. The dialog holds the days, the two times side
   by side and a line with the resolved period and its length. */
.range-zoom.range-custom { gap: 2px; padding: 0 3px 0 0; }
.range-zoom.range-custom .range-custom-edit { height: 25px; padding: 0 6px 0 10px; gap: 6px; background: none; color: inherit; }
.range-zoom.range-custom .range-custom-edit:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.range-zoom.range-custom .range-custom-x { width: 21px; padding: 0; justify-content: center; }
.range-dlg .range-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.range-dlg .range-sum { display: flex; align-items: center; gap: 7px; min-height: 18px; color: var(--ink-2); font-size: 12.5px; }
.range-dlg .range-sum .icon { color: var(--ink-3); }

/* Palette key (gallery and docs): a family's swatch, name and hex. */
.m-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.m-swatch { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 9px; align-items: center; font-size: 12px; }
.m-swatch i { grid-row: span 2; width: 28px; height: 28px; border-radius: 7px; background: var(--tone); }
.m-swatch b { font-weight: 600; color: var(--ink); }
.m-swatch span { font: 500 10.5px var(--font-data); color: var(--ink-3); }

/* Volume bars in a family's hue below the threshold (MountBar Tone); above it they stay critical. */
.mount.toned:not(.crit) .bar span { background: var(--tone); }
/* A volume stays inside its card at every width: a long mount path breaks instead of pushing the figure out, and the
   « Au-dessus du seuil » flag keeps its words together, dropping under the size when the line is short. */
.mount-top .data { min-width: 0; overflow-wrap: anywhere; }
.mount-top .v { flex: none; }
.mount-sub { flex-wrap: wrap; row-gap: 3px; }
.mount-sub .flag { white-space: nowrap; }

@media (max-width: 1100px) {
  .kpis.mkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Five figures on three columns: the fifth takes the rest of its row. */
  .mkpis > .kpi:nth-child(5):last-child { grid-column: span 2; }
}
@media (max-width: 720px) {
  .kpis.mkpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mkpis > .kpi:nth-child(5):last-child { grid-column: 1 / -1; }
  .mkpi { grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "value" "spark" "sub"; }
  .mkpi-spark { margin-top: 6px; height: 24px; }
  /* Two figures a row are narrow: a subline (« Moyenne 24,5 % · pic 99,6 % ») may take two lines, so each holds two and none
     grows when its words land. */
  .mkpi .kpi-sub { align-items: flex-start; min-height: 34.5px; }
}
@media (max-width: 640px) {
  .tc-box { height: calc(var(--tc-h, 180px) * 0.82); }
  .tc-note .btn { margin-top: 2px; }
  .tc-skel, .tc-state { height: calc(var(--tc-h, 180px) * 0.82); min-height: 0; }
  .tc-tip { font-size: 11px; }
}
