/* -------------------------------------------------------------------------
   n8n Dashboard — Oberflaeche
   Dunkles Grundlayout, n8n-Rot als einzige Signalfarbe fuer Aktionen,
   Gruen/Rot/Gelb ausschliesslich fuer Zustaende.
   ------------------------------------------------------------------------- */

:root {
  --grund: #0f1115;
  --flaeche: #171a21;
  --flaeche-hoch: #1e222b;
  --rand: #272c37;
  --rand-stark: #343a47;

  --text: #e7e9ee;
  --text-leise: #9aa1b1;
  --text-sehr-leise: #6b7280;

  --marke: #ea4b71;
  --marke-dunkel: #cf3a5e;

  --gut: #3ec98a;
  --gut-grund: rgba(62, 201, 138, 0.12);
  --schlecht: #f2555a;
  --schlecht-grund: rgba(242, 85, 90, 0.12);
  --warn: #f0b429;
  --warn-grund: rgba(240, 180, 41, 0.12);
  --neutral-grund: rgba(154, 161, 177, 0.12);

  --radius: 10px;
  --radius-klein: 6px;
  --schatten: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

/* Muss vor allen display-Regeln stehen: sonst ueberstimmt z. B.
   .anmelde-huelle { display: grid } das hidden-Attribut. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--grund);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--marke);
  outline-offset: 2px;
}

/* --- Marke ---------------------------------------------------------------- */

.marke-punkt {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--marke);
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(234, 75, 113, 0.18);
}

/* --- Anmeldung ------------------------------------------------------------ */

.anmelde-huelle {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.anmelde-karte {
  width: 100%;
  max-width: 380px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--schatten);
}

.anmelde-marke {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.anmelde-marke h1 {
  font-size: 18px;
  font-weight: 600;
}

.anmelde-hinweis {
  color: var(--text-leise);
  margin-bottom: 24px;
  font-size: 13px;
}

.feld {
  display: block;
  margin-bottom: 16px;
}

.feld-name {
  display: block;
  font-size: 12px;
  color: var(--text-leise);
  margin-bottom: 6px;
}

.feld input {
  width: 100%;
  padding: 10px 12px;
  background: var(--grund);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
}

.feld input:focus {
  border-color: var(--marke);
  outline: none;
}

.fehlerzeile {
  color: var(--schlecht);
  font-size: 13px;
  margin-bottom: 14px;
}

/* --- Knoepfe -------------------------------------------------------------- */

.knopf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-klein);
  border: 1px solid var(--rand-stark);
  background: var(--flaeche-hoch);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.knopf:hover:not(:disabled) {
  background: #262b36;
  border-color: #414857;
}

.knopf:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.knopf-primaer {
  background: var(--marke);
  border-color: var(--marke);
  color: #fff;
  font-weight: 500;
}

.knopf-primaer:hover:not(:disabled) {
  background: var(--marke-dunkel);
  border-color: var(--marke-dunkel);
}

.knopf-still {
  background: transparent;
  color: var(--text-leise);
}

.knopf-breit {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

.knopf-klein {
  padding: 5px 10px;
  font-size: 13px;
}

.knopf-symbol {
  display: inline-block;
  font-size: 15px;
  line-height: 1;
}

.laedt .knopf-symbol {
  animation: dreht 0.8s linear infinite;
}

@keyframes dreht {
  to {
    transform: rotate(360deg);
  }
}

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

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 20;
}

.kopf-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kopf-titel {
  font-size: 16px;
  font-weight: 600;
}

.kopf-unterzeile {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-leise);
}

.kopf-rechts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.aktualisierung {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.35;
  margin-right: 4px;
}

.stand-text {
  font-size: 12px;
  color: var(--text-leise);
}

.countdown {
  font-size: 11px;
  color: var(--text-sehr-leise);
  font-variant-numeric: tabular-nums;
}

.status-punkt {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.status-gut {
  background: var(--gut);
}

.status-schlecht {
  background: var(--schlecht);
}

.status-unbekannt {
  background: var(--text-sehr-leise);
}

/* --- Banner --------------------------------------------------------------- */

.banner {
  margin: 16px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius-klein);
  font-size: 13px;
}

.banner-fehler {
  background: var(--schlecht-grund);
  border: 1px solid rgba(242, 85, 90, 0.35);
  color: #ffb3b5;
}

/* --- Kennzahlen ----------------------------------------------------------- */

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  padding: 20px 24px 4px;
}

.kachel {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kachel-name {
  font-size: 12px;
  color: var(--text-leise);
  margin-bottom: 6px;
}

.kachel-wert {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kachel-fuss {
  font-size: 11px;
  color: var(--text-sehr-leise);
  margin-top: 4px;
}

.kachel-gut .kachel-wert {
  color: var(--gut);
}

.kachel-warnung.hat-fehler .kachel-wert {
  color: var(--schlecht);
}

/* --- Werkzeugleiste ------------------------------------------------------- */

.werkzeugleiste {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 24px;
}

.suchfeld {
  position: relative;
  flex: 1 1 240px;
  max-width: 340px;
}

.such-symbol {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-sehr-leise);
  font-size: 16px;
}

.suchfeld input {
  width: 100%;
  padding: 8px 12px 8px 30px;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
}

.suchfeld input:focus {
  border-color: var(--marke);
  outline: none;
}

.segmente {
  display: inline-flex;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
  padding: 2px;
}

.segment {
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--text-leise);
  border-radius: 4px;
  cursor: pointer;
}

.segment.ist-aktiv {
  background: var(--flaeche-hoch);
  color: var(--text);
}

.werkzeugleiste select {
  padding: 8px 10px;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
}

.treffer {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-sehr-leise);
}

/* --- Tabelle -------------------------------------------------------------- */

.tabellen-huelle {
  margin: 0 24px 24px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  overflow-x: auto;
}

.tabelle {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.tabelle th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sehr-leise);
  padding: 10px 16px;
  border-bottom: 1px solid var(--rand);
  background: var(--flaeche);
  position: sticky;
  top: 0;
}

.tabelle td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(39, 44, 55, 0.6);
  vertical-align: middle;
}

.tabelle tbody tr:last-child td {
  border-bottom: 0;
}

.tabelle tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.spalte-status {
  width: 108px;
}
.spalte-klein {
  width: 90px;
}
.spalte-mittel {
  width: 170px;
}
.spalte-aktionen {
  width: 190px;
}

.wf-name {
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  color: var(--text);
}

.wf-name:hover {
  color: var(--marke);
}

.wf-beschreibung {
  font-size: 12px;
  color: var(--text-sehr-leise);
  margin-top: 2px;
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Schalter fuer aktiv/inaktiv */
.schalter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.schalter:disabled {
  opacity: 0.5;
  cursor: wait;
}

.schalter-bahn {
  width: 34px;
  height: 19px;
  border-radius: 10px;
  background: var(--rand-stark);
  position: relative;
  transition: background 0.15s ease;
  flex: 0 0 auto;
}

.schalter-knopf {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.schalter[aria-pressed="true"] .schalter-bahn {
  background: var(--gut);
}

.schalter[aria-pressed="true"] .schalter-knopf {
  transform: translateX(15px);
}

.schalter-text {
  font-size: 12px;
  color: var(--text-leise);
}

/* Plaketten */
.plakette {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  background: var(--neutral-grund);
  color: var(--text-leise);
}

.plakette-gut {
  background: var(--gut-grund);
  color: var(--gut);
}

.plakette-schlecht {
  background: var(--schlecht-grund);
  color: var(--schlecht);
}

.plakette-warn {
  background: var(--warn-grund);
  color: var(--warn);
}

.tag-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--flaeche-hoch);
  border: 1px solid var(--rand);
  color: var(--text-leise);
}

.leise {
  color: var(--text-sehr-leise);
  font-size: 12px;
}

.zeit-zusatz {
  display: block;
  font-size: 11px;
  color: var(--text-sehr-leise);
}

.aktionen {
  display: flex;
  gap: 6px;
}

.leer {
  padding: 40px;
  text-align: center;
  color: var(--text-sehr-leise);
}

.fuss {
  padding: 0 24px 32px;
  font-size: 11px;
  color: var(--text-sehr-leise);
}

/* --- Detailansicht -------------------------------------------------------- */

.detail-huelle {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.detail-schatten {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.detail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100%);
  background: var(--flaeche);
  border-left: 1px solid var(--rand);
  display: flex;
  flex-direction: column;
  box-shadow: var(--schatten);
}

.detail-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rand);
}

.detail-kopf h2 {
  font-size: 15px;
  font-weight: 600;
}

.detail-inhalt {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.detail-block {
  margin-bottom: 24px;
}

.detail-block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sehr-leise);
  margin-bottom: 10px;
}

.detail-paare {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.detail-paare dt {
  color: var(--text-leise);
}

.detail-paare dd {
  margin: 0;
}

.lauf-liste {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lauf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(39, 44, 55, 0.6);
  font-size: 13px;
}

.lauf:last-child {
  border-bottom: 0;
}

/* --- Hinweise (Toasts) ---------------------------------------------------- */

.hinweise {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.hinweis {
  padding: 10px 14px;
  border-radius: var(--radius-klein);
  background: var(--flaeche-hoch);
  border: 1px solid var(--rand-stark);
  box-shadow: var(--schatten);
  font-size: 13px;
  max-width: 340px;
}

.hinweis-gut {
  border-color: rgba(62, 201, 138, 0.4);
}

.hinweis-schlecht {
  border-color: rgba(242, 85, 90, 0.45);
  color: #ffb3b5;
}

/* --- Ladezustand ---------------------------------------------------------- */

.platzhalter-zeile td {
  padding: 14px 16px;
}

.platzhalter {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #1e222b 25%, #262b36 50%, #1e222b 75%);
  background-size: 200% 100%;
  animation: schimmer 1.3s infinite;
}

@keyframes schimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .platzhalter,
  .laedt .knopf-symbol {
    animation: none;
  }
}

/* --- Schmale Bildschirme -------------------------------------------------- */

@media (max-width: 720px) {
  .kopf,
  .kennzahlen,
  .werkzeugleiste,
  .fuss {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tabellen-huelle {
    margin-left: 14px;
    margin-right: 14px;
  }

  .aktualisierung {
    align-items: flex-start;
  }

  .treffer {
    margin-left: 0;
  }
}

/* --- Reiter --------------------------------------------------------------- */

.reiter {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--rand);
  margin-bottom: 4px;
}

.reiter-knopf {
  padding: 9px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-leise);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: -1px;
}

.reiter-knopf:hover {
  color: var(--text);
}

.reiter-knopf.ist-aktiv {
  color: var(--text);
  border-bottom-color: var(--marke);
}

/* --- Warnbanner ----------------------------------------------------------- */

.banner-warnung {
  background: var(--warn-grund);
  border: 1px solid rgba(240, 180, 41, 0.4);
  color: #f6d488;
}

.banner-warnung strong {
  color: var(--warn);
}

.banner-warnung ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* --- Hinweiskasten -------------------------------------------------------- */

.hinweiskasten {
  margin: 0 24px 20px;
  padding: 16px 18px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-left: 3px solid var(--marke);
  border-radius: var(--radius);
}

.hinweiskasten h3 {
  font-size: 13px;
  margin-bottom: 10px;
}

.hinweiskasten p {
  font-size: 12px;
  color: var(--text-leise);
  margin-bottom: 8px;
  max-width: 90ch;
}

.hinweiskasten p:last-child {
  margin-bottom: 0;
}

.hinweiskasten strong {
  color: var(--text);
  font-weight: 500;
}

.hinweiskasten code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--flaeche-hoch);
  border: 1px solid var(--rand);
}

/* --- Abschnittsueberschriften --------------------------------------------- */

.abschnitt {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 24px 0;
  margin-top: 8px;
}

.abschnitt-hinweis {
  font-size: 12px;
  color: var(--text-sehr-leise);
  padding: 2px 24px 10px;
}

.abschnitt + .tabellen-huelle,
.abschnitt-hinweis + .tabellen-huelle {
  margin-top: 10px;
}

/* --- Anteilsbalken -------------------------------------------------------- */

.balken-huelle {
  height: 6px;
  border-radius: 3px;
  background: var(--flaeche-hoch);
  overflow: hidden;
  min-width: 80px;
}

.balken {
  height: 100%;
  background: var(--marke);
  border-radius: 3px;
}

/* --- Zahlen --------------------------------------------------------------- */

.zahl {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.geld {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--gut);
}

.geld-null {
  color: var(--text-sehr-leise);
}

/* --- Sammelauswahl -------------------------------------------------------- */

.spalte-haken {
  width: 40px;
}

.sammelleiste {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 24px 12px;
  padding: 10px 14px;
  background: var(--flaeche-hoch);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
  font-size: 13px;
}

.sammelleiste span {
  margin-right: auto;
}

input[type="checkbox"] {
  accent-color: var(--marke);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

/* --- Modellkennzeichen ---------------------------------------------------- */

.modell {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--flaeche-hoch);
  border: 1px solid var(--rand);
  color: var(--text-leise);
  margin-right: 4px;
}

@media (max-width: 720px) {
  .reiter,
  .hinweiskasten,
  .abschnitt,
  .abschnitt-hinweis,
  .sammelleiste {
    padding-left: 14px;
    padding-right: 14px;
    margin-left: 0;
    margin-right: 0;
  }
}
