/* Komponenten: Alert-Banner, KPI-Karten mit Donut/Gauge, Stations-Karten,
   Buttons. Generischer Industrie-Dashboard-Stil. */

/* ---------- ALERT BANNER ---------- */
.alert-banner {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(95deg, var(--bad-softer) 0%, var(--warn-softer) 100%);
  border: 1px solid var(--bad-soft);
  border-left: 4px solid var(--bad);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.alert-banner.is-clear {
  background: linear-gradient(95deg, var(--ok-softer) 0%, var(--ok-softer) 100%);
  border-color: var(--ok-soft);
  border-left-color: var(--ok);
}
.alert-banner .alert-ic {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bad);
  color: #ffffff;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.32);
}
.alert-banner.is-clear .alert-ic { background: var(--ok); box-shadow: 0 4px 10px rgba(22, 163, 74, 0.28); }
.alert-banner .alert-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.alert-banner .alert-title {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 15.5px; font-weight: 600;
  color: var(--ink);
}
.alert-banner .alert-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bad);
  color: #ffffff;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.alert-banner.is-clear .alert-tag { background: var(--ok); }
.alert-banner .alert-tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #ffffff;
  animation: pulse-soft 1.6s ease-in-out infinite;
}
.alert-banner.is-clear .alert-tag .dot { animation: none; }
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.alert-banner .alert-sub { font-size: 13px; color: var(--ink-2); }
.alert-banner .alert-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- BUTTONS ---------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--primary-2);
  color: #ffffff;
  border: 1px solid var(--primary-2);
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.22);
  transition: filter 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28), 0 6px 12px rgba(37, 99, 235, 0.18); }
.btn:active { transform: translateY(0); }
.btn.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-1);
}
.btn.btn-secondary:hover { background: var(--canvas); border-color: var(--muted-2); }
.btn.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.22);
}
.btn.btn-danger:hover { box-shadow: 0 2px 6px rgba(220, 38, 38, 0.32), 0 6px 12px rgba(220, 38, 38, 0.20); }
.btn.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  box-shadow: none;
}
.btn.btn-ghost:hover { background: var(--canvas); }
.btn.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.btn-lg { height: 42px; padding: 0 20px; font-size: 14px; font-weight: 600; }

/* ---------- SECTION HEADER ---------- */
.sec-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px;
}
.sec-head h2 {
  font-size: 16px; font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.sec-head .sec-sub { font-size: 12px; color: var(--muted); margin-left: 2px; }
.sec-head .sec-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.sec-head .sec-meta {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted);
}
.sec-head .sec-meta svg { color: var(--ok-2); }
.sec-head .btn-ghost svg { margin-right: 1px; }

/* ---------- KPI CARDS ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  padding: 16px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
  cursor: default;
}
.kpi-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kpi-card.is-active { border-color: var(--primary-3); box-shadow: 0 0 0 3px var(--primary-softer), var(--shadow-1); }
.kpi-card.kpi-warn { border-top: 3px solid var(--warn); padding-top: 13px; }
.kpi-card.kpi-bad { border-top: 3px solid var(--bad); padding-top: 13px; }
.kpi-card.kpi-ok { border-top: 3px solid var(--ok-2); padding-top: 13px; }

.kpi-card.kpi-prominent { grid-column: span 2; }
@media (max-width: 1480px) { .kpi-card.kpi-prominent { grid-column: span 2; } }
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } .kpi-card.kpi-prominent { grid-column: span 1; } }
@media (max-width: 780px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-head {
  display: flex; align-items: center; gap: 8px;
}
.kpi-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-2);
  background: var(--primary-softer);
  color: var(--primary-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.kpi-warn .kpi-icon { background: var(--warn-softer); color: var(--warn); }
.kpi-bad .kpi-icon { background: var(--bad-softer); color: var(--bad); }
.kpi-ok .kpi-icon { background: var(--ok-softer); color: var(--ok); }

.kpi-label {
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  flex: 1; min-width: 0;
}
.kpi-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--canvas);
  color: var(--muted);
}
.kpi-trend.trend-up { background: var(--ok-soft); color: var(--ok); }
.kpi-trend.trend-down { background: var(--bad-soft); color: var(--bad); }
.kpi-trend.trend-flat { background: var(--canvas); color: var(--muted); }

.kpi-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.kpi-value-block { display: flex; flex-direction: column; }
.kpi-value {
  font-family: var(--mono);
  font-size: 30px; font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-value .unit { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi-warn .kpi-value, .kpi-bad .kpi-value { color: var(--bad); }
.kpi-meta {
  font-size: 11.5px; color: var(--muted);
  margin-top: 6px;
  display: flex; flex-direction: column; gap: 1px;
}
.kpi-meta .delta { font-weight: 500; }
.kpi-warn .kpi-meta .delta { color: var(--warn); }
.kpi-bad .kpi-meta .delta { color: var(--bad); }
.kpi-ok .kpi-meta .delta { color: var(--ok); }

.kpi-gauge {
  width: 64px; height: 64px;
  position: relative;
  flex-shrink: 0;
}
.kpi-gauge svg { width: 100%; height: 100%; }
.kpi-gauge .gauge-track { fill: none; stroke: var(--line-3); stroke-width: 7; }
.kpi-gauge .gauge-arc { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray 400ms ease; }
.kpi-warn .kpi-gauge .gauge-arc { stroke: var(--warn); }
.kpi-bad .kpi-gauge .gauge-arc { stroke: var(--bad); }
.kpi-ok .kpi-gauge .gauge-arc { stroke: var(--ok-2); }
.kpi-card:not(.kpi-warn):not(.kpi-bad):not(.kpi-ok) .kpi-gauge .gauge-arc { stroke: var(--primary-2); }
.kpi-gauge .gauge-text {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  color: var(--ink);
}

.kpi-spark {
  height: 32px;
  width: 100%;
}
.kpi-spark .spark-area { opacity: 0.18; }
.kpi-spark .spark-line { fill: none; stroke-width: 1.8; }
.kpi-warn .kpi-spark .spark-line { stroke: var(--warn); }
.kpi-warn .kpi-spark .spark-area { fill: var(--warn); }
.kpi-bad .kpi-spark .spark-line { stroke: var(--bad); }
.kpi-bad .kpi-spark .spark-area { fill: var(--bad); }
.kpi-ok .kpi-spark .spark-line { stroke: var(--ok-2); }
.kpi-ok .kpi-spark .spark-area { fill: var(--ok-2); }
.kpi-card:not(.kpi-warn):not(.kpi-bad):not(.kpi-ok) .kpi-spark .spark-line { stroke: var(--primary-2); }
.kpi-card:not(.kpi-warn):not(.kpi-bad):not(.kpi-ok) .kpi-spark .spark-area { fill: var(--primary-2); }

/* ---------- STATIONS ---------- */
.stations-section { display: flex; flex-direction: column; gap: 14px; }

.station-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.station-warn {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 20px;
  padding: 18px 20px;
  align-items: center;
  border-left: 4px solid var(--bad);
  background: linear-gradient(95deg, var(--bad-softer) 0%, var(--surface) 60%);
}
.station-warn .st-status {
  width: 56px; height: 56px;
  background: var(--bad);
  color: #ffffff;
  border-radius: var(--radius-2);
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.28);
}
.station-warn .st-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.station-warn .st-title {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.station-warn .st-id {
  font-family: var(--mono); font-size: 12px;
  color: var(--muted);
  background: var(--canvas);
  padding: 2px 8px;
  border-radius: var(--radius-1);
  border: 1px solid var(--line);
  font-weight: 500;
}
.station-warn .st-name {
  font-size: 17px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
}
.station-warn .st-status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bad);
  color: #ffffff;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.station-warn .st-status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #ffffff; animation: pulse-soft 1.6s ease-in-out infinite; }
.station-warn .st-note {
  font-size: 13px; color: var(--bad);
  font-weight: 500;
}
.station-warn .st-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.station-warn .st-meta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--muted);
  background: var(--canvas);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}
.station-warn .st-meta-pill .av {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--av, var(--primary-2));
  color: #ffffff;
  display: grid; place-items: center;
  font-size: 8.5px; font-weight: 600;
}
.station-warn .st-rate {
  display: flex; flex-direction: column; text-align: right;
}
.station-warn .st-rate .v {
  font-family: var(--mono); font-size: 28px; font-weight: 700;
  color: var(--bad);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.station-warn .st-rate .of { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.station-warn .st-actions { display: flex; gap: 8px; }

/* ---------- STATIONS GRID OK ---------- */
.stations-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.stations-grid-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.stations-grid-head .lbl { font-size: 13px; font-weight: 600; color: var(--ink); }
.stations-grid-head .count {
  font-size: 11.5px; color: var(--ok);
  background: var(--ok-softer);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ok-soft);
  font-weight: 500;
}
.stations-grid-head .right { margin-left: auto; font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

.stations-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.station-ok {
  padding: 14px 16px;
  border-right: 1px solid var(--line-3);
  display: flex; flex-direction: column; gap: 8px;
  cursor: default;
  transition: background-color 120ms ease;
}
.station-ok:last-child { border-right: 0; }
.station-ok:hover { background: var(--canvas); }
.station-ok .row-1 {
  display: flex; justify-content: space-between; align-items: center;
}
.station-ok .st-id {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  background: var(--canvas);
  padding: 2px 7px;
  border-radius: var(--radius-1);
  border: 1px solid var(--line);
}
.station-ok .st-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  color: var(--ok);
  background: var(--ok-softer);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.station-ok .st-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok-2); }
.station-ok .st-name {
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  letter-spacing: -0.003em;
}
.station-ok .st-rate-bar {
  display: flex; flex-direction: column; gap: 4px;
}
.station-ok .st-rate-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.station-ok .st-rate-row b { font-size: 14px; font-weight: 600; color: var(--ink); }
.station-ok .st-rate-row .of { color: var(--muted); }
.station-ok .st-bar {
  height: 4px;
  background: var(--line-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.station-ok .st-bar span {
  display: block; height: 100%;
  background: var(--ok-2);
  border-radius: var(--radius-pill);
}
.station-ok .st-worker {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted);
}
.station-ok .st-worker .av {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--av, var(--primary-2));
  color: #ffffff;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 600;
  flex-shrink: 0;
}

@media (max-width: 1280px) {
  .stations-row { grid-template-columns: repeat(3, 1fr); }
  .station-ok { border-bottom: 1px solid var(--line-3); }
}
@media (max-width: 720px) {
  .stations-row { grid-template-columns: 1fr; }
  .station-warn { grid-template-columns: 1fr; gap: 12px; }
  .station-warn .st-rate { text-align: left; }
}

/* ---------- TOASTS ---------- */
.toast-host {
  position: fixed; top: 70px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary-2);
  border-radius: var(--radius-2);
  padding: 12px 14px 12px 12px;
  box-shadow: var(--shadow-3);
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 360px;
  animation: toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.is-out { animation: toast-out 200ms ease forwards; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(24px); opacity: 0; }
}
.toast.toast-ok { border-left-color: var(--ok); }
.toast.toast-warn { border-left-color: var(--warn); }
.toast.toast-bad { border-left-color: var(--bad); }
.toast .toast-ic {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary-softer); color: var(--primary-2);
  display: grid; place-items: center; flex-shrink: 0;
  margin-top: 1px;
}
.toast.toast-ok .toast-ic { background: var(--ok-softer); color: var(--ok); }
.toast.toast-warn .toast-ic { background: var(--warn-softer); color: var(--warn); }
.toast.toast-bad .toast-ic { background: var(--bad-softer); color: var(--bad); }
.toast .toast-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toast .toast-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.toast .toast-msg { font-size: 12px; color: var(--ink-2); }
.toast .toast-close {
  appearance: none; background: transparent; border: 0;
  color: var(--muted); cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 4px;
  display: grid; place-items: center;
}
.toast .toast-close:hover { background: var(--canvas); color: var(--ink); }
