/* 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;
}

/* ---------------------------------------------------------- Kundenansicht */

.cv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.cv-head h3 { margin-top: 0; }

/* Logos von Subadmin (ILI) und Kunde rechts oben; das ARGOS-Zeichen bleibt
   in der Navigationsleiste. */
.cv-logos {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-left: auto;
}

/* ARGOS-Zeichen in der Leiste (.brand-mark, 1.6rem) + 30 % auf Wunsch */
.cv-logo {
  display: block;
  height: 2.1rem;
  width: auto;
  max-width: 6.5rem;
  object-fit: contain;
}

/* Dunkler Modus: helle Unterlage, sonst verschwinden schwarze Konturen */
:root[data-theme="dark"] .cv-logos {
  padding: .3rem .6rem;
  background: #fff;
  border-radius: 8px;
}

.cv-section { margin: 1.25rem 0 .5rem; }

.cv-machines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr));
  gap: 1rem;
  align-items: start;
}

.cv-machine-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.cv-machine-head h3 { margin: 0; }

.cv-chart { margin: .5rem 0; min-height: 4rem; }

.cv-states {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .75rem;
  margin: .75rem 0;
}

.cv-state {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cv-state-sym { font-size: 1.7rem; line-height: 1; }
.cv-state-label { font-size: .78rem; color: var(--ink-soft); }
.cv-state-value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.cv-state-detail { font-size: .76rem; }

/* Gesamtampel als gefüllte Fläche (Farbverlauf aus .fill-*) */
.cv-state-fill {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
}
.cv-state-fill > * { position: relative; }
.cv-state-fill .cv-state-label { color: inherit; opacity: .85; }
.cv-state-fill .cv-state-value { font-weight: 700; }

.cv-aggs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .6rem;
}

/* Gefüllte Ampelflächen wie in der Skizze. Dunkle Schrift auf Grün und Gelb,
   weiße auf Rot - jeweils über 4,5:1. Symbol und Text tragen die Aussage
   zusätzlich zur Farbe. */
.cv-agg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: 1.1rem .8rem;
  text-align: center;
  border-radius: 14px;
  overflow: hidden;
}

/* Lichtkante oben: wirkt wie eine leicht gewölbte Fläche */
.cv-agg::before, .cv-state-fill::before {
  content: '';
  position: absolute;
  inset: 0 0 55% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.cv-agg-name { position: relative; font-size: 1.35rem; font-weight: 700; letter-spacing: .01em; }
.cv-agg-state {
  position: relative;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .85;
}

/* Farbverläufe je Status. Der dunkle Endpunkt ist jeweils der geprüfte
   Statuston aus der Palette; Schrift dunkel auf Grün/Gelb, weiß auf Rot. */
.fill-ok {
  background: linear-gradient(135deg, #5fd86b 0%, #1fb330 45%, #0a8a0a 100%);
  color: #06210a;
  box-shadow: 0 6px 18px -6px rgba(12, 163, 12, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
}

.fill-warn {
  background: linear-gradient(135deg, #ffe27a 0%, #fbbf2a 45%, #f29a0c 100%);
  color: #2b1d00;
  box-shadow: 0 6px 18px -6px rgba(242, 154, 12, .6), inset 0 1px 0 rgba(255, 255, 255, .45);
}

.fill-crit {
  background: linear-gradient(135deg, #e65a5a 0%, #c62f2f 50%, #961c1c 100%);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  box-shadow: 0 6px 18px -6px rgba(208, 59, 59, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.cv-finding {
  margin-top: .75rem;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cv-part {
  display: inline-block;
  margin-bottom: .5rem;
  padding: .4rem .85rem;
  font-weight: 600;
  border-radius: 99px;
}

.cv-text-label {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cv-text p { margin: .15rem 0 .55rem; font-size: .9rem; }
.cv-meta { font-size: .76rem; }

/* 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; }
  .cv-agg, .cv-part, .cv-state-fill { border: 1px solid CanvasText; }
}
