/* ============================================================
   Automations-Board — Kontrollraum, kein Schaufenster.
   Datendicht, funktionale Farbe, Zahlen in Tabellenziffern.
   Kein Build-Step: reines CSS auf den Brand-Tokens.
   ============================================================ */

:root {
  --b-bg:        #0B0C0E;
  --b-surface:   #131519;
  --b-surface-2: #1A1D22;
  --b-line:      #262A31;
  --b-line-soft: #1E2228;
  --b-text:      #E8EAED;
  --b-text-dim:  #9AA0A8;
  --b-text-mute: #6B7078;

  /* Zustandsfarben. Sie tragen Bedeutung, nicht Dekoration —
     deshalb überall zusätzlich ein Textlabel und eine Form. */
  --b-alarm:   #FF4D5E;
  --b-alarm-bg:rgba(255,77,94,0.10);
  --b-warn:    #F5A524;
  --b-warn-bg: rgba(245,165,36,0.10);
  --b-blind:   #8B5CF6;   /* eigene Farbe: "ich weiß es nicht" ist kein Fehler */
  --b-blind-bg:rgba(139,92,246,0.10);
  --b-ok:      #2ECC71;
  --b-ok-bg:   rgba(46,204,113,0.09);
  --b-idle:    #5C6169;

  --b-accent:  #C30017;   /* G&B Rot bleibt der Markenakzent */

  --b-mono: "DM Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --b-sans: "Montserrat", "Helvetica Neue", Arial, sans-serif;
}

body[data-page="lage"],
body[data-page="checkliste"],
body[data-page="detail"] {
  background: var(--b-bg);
  color: var(--b-text);
  font-family: var(--b-sans);
  /* Feines Raster im Hintergrund: gibt Tiefe, ohne abzulenken */
  background-image:
    linear-gradient(var(--b-line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--b-line-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
}

.bd { max-width: 1560px; margin: 0 auto; padding: 22px 20px 72px; }

/* ---------------------------------------------------- Kopfzeile ---------- */

.bd-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.bd-head h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px;
  text-transform: uppercase;
}
.bd-head h1 em { font-style: normal; color: var(--b-accent); }
.bd-head p { margin: 0; color: var(--b-text-dim); font-size: 14px; max-width: 62ch; line-height: 1.5; }

.bd-tabs { display: flex; gap: 2px; background: var(--b-surface); border: 1px solid var(--b-line); border-radius: 8px; padding: 3px; }
.bd-tabs a {
  padding: 8px 16px; border-radius: 6px; text-decoration: none; color: var(--b-text-dim);
  font-size: 13px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}
.bd-tabs a[aria-current="page"] { background: var(--b-surface-2); color: var(--b-text); box-shadow: inset 0 0 0 1px var(--b-line); }
.bd-tabs a:hover { color: var(--b-text); }

/* ---------------------------------------------------- Kennzahlen --------- */

.bd-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 26px; }
.kpi {
  background: var(--b-surface); border: 1px solid var(--b-line); border-radius: 10px;
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--b-idle); }
.kpi--alarm::after { background: var(--b-alarm); }
.kpi--warn::after  { background: var(--b-warn); }
.kpi--ok::after    { background: var(--b-ok); }
.kpi--open::after  { background: var(--b-accent); }
.kpi__n { font-family: var(--b-mono); font-size: 34px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__l { margin-top: 7px; font-size: 12px; color: var(--b-text-dim); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi__s { margin-top: 5px; font-size: 12px; color: var(--b-text-mute); line-height: 1.4; }

/* ---------------------------------------------------- Karten ------------- */

.card {
  background: var(--b-surface); border: 1px solid var(--b-line); border-radius: 10px;
  margin-bottom: 18px; overflow: hidden;
}
.card__head {
  padding: 14px 18px; border-bottom: 1px solid var(--b-line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card__head h2 { font-size: 14px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 0.07em; }
.card__head p { margin: 3px 0 0; font-size: 12.5px; color: var(--b-text-mute); font-weight: 400; text-transform: none; letter-spacing: 0; }
.card__body { padding: 16px 18px; }
.card__body--flush { padding: 0; }

/* ---------------------------------------------------- Tabelle ------------ */

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--b-text-mute); font-weight: 700;
  border-bottom: 1px solid var(--b-line); background: var(--b-surface-2);
  position: sticky; top: 0; z-index: 2;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--b-line-soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: rgba(255,255,255,0.018); }
.tbl .num { font-family: var(--b-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .nm { font-weight: 600; }
.tbl .nm a { color: var(--b-text); text-decoration: none; }
.tbl .nm a:hover { color: var(--b-accent); text-decoration: underline; }
.tbl .sub { display: block; margin-top: 3px; color: var(--b-text-mute); font-size: 12px; font-weight: 400; line-height: 1.45; }
.tbl-wrap { overflow-x: auto; }

/* ---------------------------------------------------- Marken ------------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
  border: 1px solid transparent;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tag--alarm { color: var(--b-alarm); background: var(--b-alarm-bg); border-color: rgba(255,77,94,0.28); }
.tag--warn  { color: var(--b-warn);  background: var(--b-warn-bg);  border-color: rgba(245,165,36,0.28); }
/* "keine Sicht" bekommt eine Raute statt eines Punktes — die Aussage ist
   grundverschieden von "kaputt", und das muss man auch ohne Farbe sehen. */
.tag--blind { color: var(--b-blind); background: var(--b-blind-bg); border-color: rgba(139,92,246,0.30); }
.tag--blind::before { border-radius: 1px; transform: rotate(45deg); }
.tag--ok    { color: var(--b-ok);    background: var(--b-ok-bg);    border-color: rgba(46,204,113,0.24); }
.tag--idle  { color: var(--b-text-mute); background: rgba(255,255,255,0.03); border-color: var(--b-line); }
.tag--idle::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.krit { font-family: var(--b-mono); font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: 0.02em; }
.krit--P1 { color: #fff; background: var(--b-accent); }
.krit--P2 { color: var(--b-warn); background: var(--b-warn-bg); box-shadow: inset 0 0 0 1px rgba(245,165,36,0.3); }
.krit--P3 { color: var(--b-text-dim); background: rgba(255,255,255,0.05); }
.krit--P4 { color: var(--b-text-mute); background: transparent; box-shadow: inset 0 0 0 1px var(--b-line); }
.krit--unknown { color: var(--b-blind); background: var(--b-blind-bg); }

.grade { font-family: var(--b-mono); font-size: 11px; color: var(--b-text-mute); }

/* ------------------------------------------- Die Takt-Leiste ------------- */
/* Das Kernbild des ganzen Systems: erwarteter Takt gegen tatsächliche Läufe.
   Man sieht auf einen Blick, ob etwas schweigt — ohne eine Zahl zu lesen. */

.takt { display: flex; align-items: center; gap: 8px; }
.takt__bar {
  position: relative; width: 108px; height: 20px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--b-line) 0 1px, transparent 1px 9px);
  box-shadow: inset 0 0 0 1px var(--b-line-soft); flex: none; overflow: hidden;
}
.takt__fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px 0 0 3px; opacity: 0.85; }
.takt__fill--ok    { background: linear-gradient(90deg, rgba(46,204,113,0.55), rgba(46,204,113,0.18)); }
.takt__fill--warn  { background: linear-gradient(90deg, rgba(245,165,36,0.6), rgba(245,165,36,0.2)); }
.takt__fill--alarm { background: linear-gradient(90deg, rgba(255,77,94,0.7), rgba(255,77,94,0.25)); }
.takt__fill--blind { background: repeating-linear-gradient(45deg, rgba(139,92,246,0.3) 0 4px, transparent 4px 8px); }
.takt__now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--b-text); opacity: 0.8; }
.takt__txt { font-family: var(--b-mono); font-size: 12px; color: var(--b-text-dim); white-space: nowrap; }

/* ------------------------------------------- Der Lauf-Verlauf ------------ */
/* Ein Feld je Lauf, aelteste links, neuester rechts — die Frage "laeuft es
   nach dem Eingriff wieder?" beantwortet keine Durchschnittszahl, sondern nur
   der rechte Rand. Bewusst nicht nach Zeit aggregiert: sonst verdeckt ein
   Fehlschlag den frischen Erfolg derselben Stunde. */

.verlauf { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.verlauf i {
  flex: 1 1 0; min-width: 2px; height: 100%; border-radius: 1.5px;
  background: var(--b-line); /* Platzhalter: hier liegt (noch) kein Lauf */
}
.verlauf i[data-r="ok"]  { background: rgba(46,204,113,0.5); }
.verlauf i[data-r="bad"] { background: var(--b-alarm); }
/* Der juengste Lauf steht fuer sich: er ist die eigentliche Antwort. */
.verlauf i:last-child { box-shadow: 0 0 0 1px rgba(232,234,237,0.35); }

.verlauf__txt {
  display: block; margin-top: 5px; font-family: var(--b-mono);
  font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--b-text-mute);
  white-space: nowrap;
}
.verlauf__txt b { font-weight: 500; }
.verlauf__txt b[data-q="dead"]   { color: var(--b-alarm); }
.verlauf__txt b[data-q="wobbly"] { color: var(--b-warn); }
.verlauf__txt b[data-q="clean"]  { color: var(--b-text-dim); }

/* ---------------------------------------------------- Entscheidung ------- */

.dec { display: inline-flex; border: 1px solid var(--b-line); border-radius: 6px; overflow: hidden; }
.dec button {
  border: 0; background: transparent; color: var(--b-text-mute); font-family: var(--b-sans);
  font-size: 11.5px; font-weight: 700; padding: 6px 11px; cursor: pointer; letter-spacing: 0.02em;
}
.dec button + button { border-left: 1px solid var(--b-line); }
.dec button:hover { background: rgba(255,255,255,0.05); color: var(--b-text); }
.dec button[aria-pressed="true"] { color: #fff; }
.dec button[data-d="in"][aria-pressed="true"]  { background: rgba(46,204,113,0.22); color: var(--b-ok); }
.dec button[data-d="out"][aria-pressed="true"] { background: rgba(255,255,255,0.07); color: var(--b-text-dim); }
.dec button:disabled { opacity: 0.4; cursor: wait; }

.cost { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.cost--haken     { color: var(--b-ok); }
.cost--heartbeat { color: var(--b-warn); }
.cost--zugang    { color: var(--b-blind); }
.cost--klaerung, .cost--unknown { color: var(--b-text-mute); }

/* ---------------------------------------------------- Filter ------------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="search"] {
  background: var(--b-surface-2); color: var(--b-text); border: 1px solid var(--b-line);
  border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: var(--b-sans);
}
.filters input[type="search"] { min-width: 190px; }
.filters select:focus, .filters input:focus { outline: 2px solid var(--b-accent); outline-offset: 1px; }
.filters .clear { color: var(--b-text-mute); font-size: 12px; text-decoration: none; }
.filters .clear:hover { color: var(--b-text); text-decoration: underline; }

/* ---------------------------------------------------- Hinweise ----------- */

.note { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--b-line-soft); }
.note:last-child { border-bottom: 0; }
.note__mark { width: 3px; border-radius: 2px; flex: none; background: var(--b-idle); }
.note--critical .note__mark { background: var(--b-alarm); }
.note--warn .note__mark { background: var(--b-warn); }
.note__t { font-weight: 600; font-size: 13.5px; margin: 0 0 4px; }
.note__d { margin: 0; font-size: 12.5px; color: var(--b-text-dim); line-height: 1.55; white-space: pre-line; }

.empty { padding: 40px 20px; text-align: center; color: var(--b-text-mute); font-size: 14px; }
.empty strong { display: block; color: var(--b-text-dim); font-size: 15px; margin-bottom: 6px; }

.hint { font-size: 12.5px; color: var(--b-text-mute); line-height: 1.55; }
.hint code { font-family: var(--b-mono); font-size: 12px; color: var(--b-text-dim); }

/* ---------------------------------------------------- Detailseite -------- */

.det-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: 13.5px; margin: 0; }
.dl dt { color: var(--b-text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; padding-top: 2px; }
.dl dd { margin: 0; }

.runs { font-family: var(--b-mono); font-size: 12.5px; }
.runs td { padding: 7px 12px; }

/* ---------------------------------------------------- Konkrete Fälle ---- */

.case-section-title {
  margin: 0 0 8px; font-size: 12px; color: var(--b-text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.case-section-title--done { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--b-line); }
.case-empty { margin: 0; }
.case-list { margin: 0; padding: 0; list-style: none; }
.case-item { padding: 13px 0; border-top: 1px solid var(--b-line-soft); }
.case-item:first-child { border-top: 0; }
.case-item--done { opacity: 0.9; }
.case-item__head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13.5px; }
.case-detail { margin: 0 0 10px; }
.case-by { margin: -3px 0 9px; }
.case-note {
  display: block; width: 100%; resize: vertical; box-sizing: border-box;
  min-height: 62px; padding: 8px 10px; border: 1px solid var(--b-line);
  border-radius: 6px; background: var(--b-surface-2); color: var(--b-text);
  font: 12.5px/1.45 var(--b-sans);
}
.case-note:focus { outline: 2px solid var(--b-accent); outline-offset: 1px; }
.case-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.case-actions button {
  border: 1px solid var(--b-line); border-radius: 6px; padding: 6px 10px;
  background: transparent; color: var(--b-text-dim); font: 700 11.5px var(--b-sans); cursor: pointer;
}
.case-actions button:hover { color: var(--b-text); background: rgba(255,255,255,0.05); }
.case-actions button:disabled { opacity: 0.4; cursor: wait; }
.case-actions .case-done { border-color: rgba(46,204,113,0.35); color: var(--b-ok); }
.case-history { margin: 10px 0 0; padding: 0; list-style: none; font-size: 11.5px; line-height: 1.55; color: var(--b-text-mute); }
.case-history li { padding-top: 4px; overflow-wrap: anywhere; }
.case-boundary { margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--b-line-soft); }

/* ---------------------------------------------------- Mobil -------------- */

@media (max-width: 1100px) {
  .det-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .bd { padding: 16px 13px 56px; }
  .bd-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .bd-head h1 { font-size: 23px; }
  .bd-tabs { width: 100%; }
  .bd-tabs a { flex: 1; text-align: center; padding: 9px 8px; font-size: 12.5px; }
  .bd-kpis { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .kpi { padding: 13px 14px; }
  .kpi__n { font-size: 27px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input[type="search"] { width: 100%; }
  /* Tabelle wird zur Kartenliste — horizontales Scrollen ist auf dem Telefon
     die schlechteste aller Lösungen. */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border: 1px solid var(--b-line); border-radius: 9px; margin-bottom: 10px; padding: 11px 13px; background: var(--b-surface-2); }
  .tbl td { border: 0; padding: 4px 0; }
  .tbl td::before {
    content: attr(data-l); display: block; font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--b-text-mute); font-weight: 700; margin-bottom: 2px;
  }
  .tbl td:first-child::before { display: none; }
  .takt__bar { width: 84px; }
  .dl { grid-template-columns: 1fr; gap: 3px 0; }
  .dl dt { margin-top: 9px; }
}
@media (max-width: 480px) {
  .bd-kpis { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .kpi, .card { animation: bd-rise 0.34s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
  .bd-kpis .kpi:nth-child(2) { animation-delay: 0.04s; }
  .bd-kpis .kpi:nth-child(3) { animation-delay: 0.08s; }
  .bd-kpis .kpi:nth-child(4) { animation-delay: 0.12s; }
  .bd-kpis .kpi:nth-child(5) { animation-delay: 0.16s; }
  @keyframes bd-rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
}

@media print {
  body[data-page] { background: #fff; color: #000; }
  .bd-tabs, .dec, .filters { display: none; }
}

/* --- GBSERVER-Wiederanlauf (BLD-571) ---------------------------------------
   Reine Anzeige: Die Seite hat keine Formulare und keine Schaltflächen. Ihre
   einzige Aufgabe ist, nach einem Neustart in wenigen Sekunden lesbar zu
   machen, was belegt ist und was nicht. */
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-list li {
  padding: 11px 0; border-bottom: 1px solid var(--b-line-soft);
  font-size: 13.5px; line-height: 1.5;
}
.rec-list li:last-child { border-bottom: 0; }
.rec-list li > div { color: var(--b-text-dim); margin-top: 3px; }
.rec-list .tag { margin: 0 8px; }
