/* Anlagen-Dashboard.
 *
 * Statusfarben sind FEST und folgen NICHT dem einstellbaren Farbschema - sie
 * tragen Bedeutung. Werte aus der geprüften Statuspalette (CVD-Trennung 11,3 /
 * Normalsicht 27,6 in beiden Modi). Auf hellem Grund liegt Gelb unter 3:1
 * Kontrast; deshalb trägt jede Statusanzeige zusätzlich Symbol und Text.
 */

:root {
  --st-ok:    #0ca30c;
  --st-warn:  #fab219;
  --st-crit:  #d03b3b;
  --st-stale: #898781;
  --st-none:  #898781;

  /* Diagrammtinte, ebenfalls nicht themenabhängig */
  --viz-series: #2a78d6;
  --viz-grid:   #e1e0d9;
  --viz-axis:   #c3c2b7;
  --viz-muted:  #898781;
}

:root[data-theme="dark"] {
  --viz-series: #3987e5;
  --viz-grid:   #2c2c2a;
  --viz-axis:   #383835;
}

/* ------------------------------------------------------------ Statusanzeige */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  flex: 0 0 auto;
  padding: .1rem .45rem;
  font-size: .75rem;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 99px;
}

.chip-sym { font-size: .8rem; line-height: 1; }

.chip.sev-ok    .chip-sym { color: var(--st-ok); }
.chip.sev-warn  .chip-sym { color: var(--st-warn); }
.chip.sev-crit  .chip-sym { color: var(--st-crit); }
.chip.sev-stale .chip-sym,
.chip.sev-none  .chip-sym { color: var(--st-stale); }

.chip.sev-crit { border-color: var(--st-crit); }
.chip.sev-warn { border-color: var(--st-warn); }

.sev-text-ok    { color: var(--st-ok); }
.sev-text-warn  { color: var(--st-warn); }
.sev-text-crit  { color: var(--st-crit); }
.sev-text-stale,
.sev-text-none  { color: var(--st-stale); }

.sev-border-ok    { border-left: 4px solid var(--st-ok); }
.sev-border-warn  { border-left: 4px solid var(--st-warn); }
.sev-border-crit  { border-left: 4px solid var(--st-crit); }
.sev-border-stale,
.sev-border-none  { border-left: 4px solid var(--st-stale); }

.swatch {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  border-radius: 2px;
}

.swatch.sev-warn { background: var(--st-warn); }
.swatch.sev-crit { background: var(--st-crit); }

/* ------------------------------------------------------------- Kopfbereich */

.plant-head-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.plant-head-row select { padding: .3rem .5rem; font-size: .85rem; }

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: center;
  justify-content: space-between;
}

.hero-value {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  margin: .2rem 0;
}

.hero-sym { font-size: 1.6rem; }

.hero-tiles { margin: 0; flex: 1 1 26rem; }

.device-row { display: flex; flex-direction: column; gap: .5rem; }

.device {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .8rem;
}

/* ------------------------------------------------------------ Anlagenbaum */

.plant-tree .plant-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.plant-tree .tree-leaf { padding-left: .35rem; }

.plant-point { cursor: pointer; }

.plant-point:hover { background: var(--bg); }

.plant-point:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --------------------------------------------------------------- Diagnose */

.meters { display: flex; flex-direction: column; gap: 1rem; }

.meter-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .3rem;
}

.meter-title { font-weight: 500; font-size: .9rem; }

.meter-value {
  margin-left: auto;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  position: relative;
  height: .55rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.meter-fill { height: 100%; border-radius: 99px; }

.meter-fill.sev-ok    { background: var(--st-ok); }
.meter-fill.sev-warn  { background: var(--st-warn); }
.meter-fill.sev-crit  { background: var(--st-crit); }
.meter-fill.sev-none  { background: var(--st-none); }

.meter-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink);
  opacity: .55;
}

.meter-foot { font-size: .76rem; margin-top: .25rem; }

/* -------------------------------------------------------------- Diagramme */

.chart { position: relative; }

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-svg .grid  { stroke: var(--viz-grid); stroke-width: 1; }
.chart-svg .axis  { stroke: var(--viz-axis); stroke-width: 1; }
.chart-svg .tick  { fill: var(--viz-muted); font-size: 11px;
                    font-variant-numeric: tabular-nums; }

.chart-svg .series-line {
  fill: none;
  stroke: var(--viz-series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-svg .limit { stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-svg .sev-line-warn { stroke: var(--st-warn); }
.chart-svg .sev-line-crit { stroke: var(--st-crit); }
.chart-svg .limit-label { font-size: 10px; }

.chart-svg .crosshair { stroke: var(--viz-axis); stroke-width: 1; }

.chart-svg .crosshair-dot {
  fill: var(--viz-series);
  stroke: var(--panel);
  stroke-width: 2;
}

.chart-svg .bar.sev-warn { fill: var(--st-warn); }
.chart-svg .bar.sev-crit { fill: var(--st-crit); }

.chart-tip {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -120%);
  padding: .35rem .55rem;
  font-size: .78rem;
  white-space: nowrap;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.legend {
  display: flex;
  gap: 1rem;
  margin-bottom: .5rem;
  font-size: .8rem;
  color: var(--ink-soft);
}

.legend-item { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------------------------------------------------------- Wartungsfälle */

.case {
  padding: .8rem 0;
  border-top: 1px solid var(--line);
}

.case:first-of-type { border-top: 0; }

.case-head {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .8rem;
  align-items: baseline;
  margin-bottom: .3rem;
}

.case p { margin: .2rem 0; font-size: .88rem; }

.modal-body.pad { padding: 1rem; }

.trend-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

/* Erzwungene Farben (Windows-Kontrastmodus): Symbole und Text tragen die
   Aussage weiter, die Flächen bekommen Systemfarben. */
@media (forced-colors: active) {
  .meter-fill, .swatch { forced-color-adjust: none; }
  .chip { border-color: CanvasText; }
}
