/* gb-automation-monitor — "Leitstand" Polish auf Basis von brand-tokens.css (G&B CI).
   Designrichtung: Control-Room — präzise, ruhig, monochrom, EIN scharfer roter Alarm-Akzent.
   Stack: Vanilla-CSS, kein Build. Komponentenklassen hier; Farb-/Font-/Radius-Tokens aus brand-tokens.css. */

:root {
  --surface: var(--gb-white, #fff);
  --page-bg: var(--gb-grey-50, #f6f6f6);
  --ink: var(--gb-black, #0a0a0a);
  --muted: var(--gb-grey-600, #5c5c5c);
  --faint: var(--gb-grey-500, #7a7a7a);
  --line: var(--gb-grey-200, #dcdcdc);
  --line-soft: var(--gb-grey-100, #ededed);
  --hair: rgba(10, 10, 10, 0.08);
  --red: var(--gb-red, #c30017);
  --red-hover: var(--gb-red-800, #9c0013);
  --red-wash: var(--gb-red-50, #fdf2f3);
  --ok-fg: var(--color-success-fg, #1f5e2a);
  --ok-bg: var(--color-success-bg, rgba(47, 125, 58, 0.1));
  --ok: #2f7d3a;
  --warn-fg: var(--color-warn-fg, #6b4400);
  --warn-bg: var(--color-warn-bg, #fff7e0);
  --warn: #e0a800;
  --info-fg: #14506b;
  --info-bg: #eaf2f7;
  --info: #1f6e92;

  --r-sm: var(--radius-sm, 4px);
  --r-md: var(--radius-md, 6px);
  --r-lg: var(--radius-lg, 10px);

  /* Layered, weiche Schatten für Tiefe (kein flacher Look) */
  --sh-1: 0 1px 1px rgba(10, 10, 10, 0.04), 0 1px 2px rgba(10, 10, 10, 0.05);
  --sh-2: 0 2px 4px rgba(10, 10, 10, 0.05), 0 6px 16px -6px rgba(10, 10, 10, 0.12);
  --sh-3: 0 8px 18px -6px rgba(10, 10, 10, 0.18), 0 2px 6px rgba(10, 10, 10, 0.06);

  --ease: var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  --dur: var(--dur-base, 200ms);

  --maxw: 1280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans, "Montserrat", "Helvetica Neue", Arial, sans-serif);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  /* Atmosphäre: sehr dezenter Tiefenverlauf + feines Punktraster statt flat */
  background-color: var(--page-bg);
  background-image:
    radial-gradient(rgba(10, 10, 10, 0.04) 0.5px, transparent 0.5px),
    linear-gradient(180deg, #fff 0%, var(--page-bg) 220px);
  background-size: 22px 22px, 100% 100%;
  background-attachment: fixed;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.84em; }

/* ---------- Topbar ---------- */
.gb-topbar {
  background: var(--gb-black, #0a0a0a);
  color: #fff;
  border-bottom: 3px solid var(--red);
  box-shadow: var(--sh-2);
  position: sticky;
  top: 0;
  z-index: 50;
}
.gb-topbar__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 11px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.gb-brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.gb-brand:hover { text-decoration: none; }
.gb-wings { height: 30px; width: auto; display: block; }
.gb-brand__title {
  font-weight: 700; font-size: 1.02rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.gb-topnav { display: flex; align-items: center; gap: 12px; }
.gb-user {
  color: #b8b8b8; font-size: 0.78rem; letter-spacing: 0.02em;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gb-logout { margin: 0; }

/* ---------- Buttons / inputs ---------- */
.gb-btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 8px 15px; line-height: 1.2;
  background: var(--gb-grey-100, #ededed); color: var(--ink);
  transition: background var(--dur) var(--ease), border-color var(--dur), transform 120ms, box-shadow var(--dur);
}
.gb-btn:hover { background: var(--gb-grey-200, #dcdcdc); }
.gb-btn:active { transform: translateY(1px); }
.gb-btn--primary { background: var(--red); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.gb-btn--primary:hover { background: var(--red-hover); }
.gb-btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.gb-btn--ghost:hover { background: rgba(255, 255, 255, 0.12); }
.gb-btn--block { width: 100%; padding: 12px 15px; }
.gb-btn[disabled] { opacity: 0.55; cursor: default; }

.gb-input {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); min-width: 0;
  transition: border-color 120ms, box-shadow 120ms;
}
.gb-input::placeholder { color: var(--faint); }
.gb-input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(195, 0, 23, 0.14); }
.gb-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-top: 9px; letter-spacing: 0.02em; }
.gb-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.gb-check input { accent-color: var(--red); }

/* ---------- Layout ---------- */
.gb-main { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 22px 18px 8px; flex: 1 0 auto; }
.gb-center { text-align: center; padding-top: 8vh; }
.crumbs { margin: 0 0 14px; font-size: 0.85rem; }
.gb-foot { text-align: center; color: var(--faint); font-size: 0.74rem; padding: 22px; letter-spacing: 0.02em; }

/* ---------- Login ---------- */
.gb-login { display: flex; align-items: flex-start; justify-content: center; }
.gb-login__card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); padding: 32px 30px; width: 100%; max-width: 384px; margin-top: 7vh; text-align: center;
  position: relative; overflow: hidden;
}
.gb-login__card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--red); }
.gb-login__logo { max-width: 196px; height: auto; margin: 6px auto 16px; display: block; }
.gb-login__title { margin: 0 0 3px; font-size: 1.2rem; letter-spacing: 0.03em; text-transform: uppercase; }
.gb-login__sub { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }
.gb-form { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.gb-form .gb-btn { margin-top: 18px; }
.gb-alert { border-radius: var(--r-sm); padding: 10px 12px; font-size: 0.88rem; margin: 0 0 12px; }
.gb-alert--error { background: var(--red-wash); color: var(--red); border: 1px solid #f3c1c8; }

/* ---------- Gesamt-Ampel (Hero) ---------- */
.ampel {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 20px; box-shadow: var(--sh-2);
  margin-bottom: 18px; position: relative; overflow: hidden;
}
.ampel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--gb-grey-400, #999); }
.ampel--green::before { background: var(--ok); }
.ampel--yellow::before { background: var(--warn); }
.ampel--red::before { background: var(--red); }
.ampel__dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--gb-grey-400, #999); position: relative; }
.ampel--green .ampel__dot { background: var(--ok); }
.ampel--yellow .ampel__dot { background: var(--warn); }
.ampel--red .ampel__dot { background: var(--red); }
/* Pulsierender Alarm-Ring nur bei Rot */
.ampel--red .ampel__dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--red); animation: pulse 1.8s var(--ease) infinite;
}
@keyframes pulse { 0% { transform: scale(0.7); opacity: 0.9; } 100% { transform: scale(1.8); opacity: 0; } }
.ampel__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ampel__text strong { font-size: 1.16rem; letter-spacing: 0.02em; }
.ampel--red .ampel__text strong { color: var(--red); }
.summary { list-style: none; display: flex; gap: 0; flex-wrap: wrap; margin: 0 0 0 auto; padding: 0; }
.summary li {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 74px; padding: 2px 16px; position: relative;
}
.summary li + li::before { content: ""; position: absolute; left: 0; top: 14%; bottom: 14%; width: 1px; background: var(--hair); }
.summary .num { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.summary .lbl { font-size: 0.66rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 1px; }
.summary .num.is-bad { color: var(--red); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 12px; box-shadow: var(--sh-1);
}
.toolbar #f-search { flex: 1 1 240px; }
#last-updated { margin-left: auto; font-size: 0.74rem; color: var(--faint); letter-spacing: 0.02em; white-space: nowrap; }

/* ---------- Instance groups ---------- */
.inst-group { margin-bottom: 26px; }
.inst-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 0 2px 9px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.inst-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: 0.01em; }
.inst-head .owner { font-size: 0.76rem; color: var(--faint); }
.inst-head .pill { font-size: 0.7rem; align-self: center; }
.inst-head .count { font-size: 0.76rem; color: var(--muted); }
.inst-head a { font-size: 0.8rem; margin-left: auto; align-self: center; }

/* ---------- Cards grid ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 13px 14px; box-shadow: var(--sh-1);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform 150ms var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur);
  will-change: transform;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--sh-3); border-color: var(--gb-grey-300, #bfbfbf); }
/* Status-Treatment: Alarm-Zustände heben sich ab (Tint + Keyline), ruhige Zustände bleiben kalm */
.card.s-error { background: linear-gradient(0deg, var(--red-wash), var(--red-wash)), var(--surface); border-color: #f0bcc4; box-shadow: 0 1px 2px rgba(195,0,23,.08), 0 6px 16px -8px rgba(195,0,23,.25); }
.card.s-error { border-left: 3px solid var(--red); }
.card.s-running { border-left: 3px solid var(--info); }
.card.s-waiting { border-left: 3px solid var(--warn); }
.card.s-inactive { opacity: 0.72; }
.card__top { display: flex; align-items: flex-start; gap: 9px; justify-content: space-between; }
.card__name { font-weight: 700; font-size: 0.94rem; line-height: 1.25; word-break: break-word; letter-spacing: 0.005em; }
.card__purpose { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.card__meta { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: 0.77rem; color: var(--muted); margin-top: 1px; }
.card__meta b { color: var(--ink); font-weight: 600; }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.card__foot a { font-size: 0.79rem; font-weight: 600; }
.flags { display: inline-flex; gap: 5px; flex-wrap: wrap; }

/* Fehlerquoten-Meter (Daten-Viz statt nur Text) */
.meter { display: flex; align-items: center; gap: 8px; font-size: 0.74rem; color: var(--muted); }
.meter__track { flex: 1; height: 5px; border-radius: 3px; background: var(--gb-grey-100, #ededed); overflow: hidden; min-width: 60px; }
.meter__fill { height: 100%; border-radius: 3px; background: var(--ok); transition: width 600ms var(--ease); }
.meter__fill.warn { background: var(--warn); }
.meter__fill.bad { background: var(--red); }
.meter__val { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; letter-spacing: 0.01em;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.pill.s-success { color: var(--ok-fg); background: var(--ok-bg); }
.pill.s-error { color: var(--red); background: var(--red-wash); border-color: #f3c1c8; }
.pill.s-running { color: var(--info-fg); background: var(--info-bg); }
.pill.s-waiting { color: var(--warn-fg); background: var(--warn-bg); }
.pill.s-idle, .pill.s-unknown, .pill.s-none, .pill.s-inactive { color: var(--gb-grey-700, #3a3a3a); background: var(--gb-grey-100, #ededed); }
.pill.s-pending { color: var(--warn-fg); background: var(--warn-bg); }
.pill.crit { color: var(--red); background: var(--red-wash); border-color: #f3c1c8; }
.pill.crit::before { box-shadow: none; }

.empty { color: var(--muted); padding: 22px; text-align: center; font-size: 0.9rem; border: 1px dashed var(--line); border-radius: var(--r-md); background: rgba(255,255,255,.4); }

/* ---------- Skeleton loading ---------- */
.sk-group { margin-bottom: 22px; }
.sk-head { height: 18px; width: 180px; border-radius: 4px; margin-bottom: 14px; }
.sk-card { height: 118px; border-radius: var(--r-md); border: 1px solid var(--line); }
.skel { position: relative; overflow: hidden; background: var(--gb-grey-100, #ededed); }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- Reveal (ein orchestrierter Page-Load) ---------- */
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.cards--reveal .card { animation: cardIn 0.45s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }
@media (prefers-reduced-motion: reduce) {
  .cards--reveal .card { animation: none; }
  .ampel--red .ampel__dot::after { animation: none; }
  .meter__fill { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .gb-main { padding: 16px 13px 6px; }
  .ampel { gap: 12px; padding: 14px 15px; }
  .summary { width: 100%; margin: 10px 0 0; justify-content: space-between; }
  .summary li { min-width: 0; flex: 1; padding: 2px 4px; }
  .toolbar { gap: 8px; }
  #last-updated { width: 100%; margin: 0; }
  .cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .gb-user { display: none; }
  .gb-topbar__inner { padding: 10px 13px; }
  .gb-brand__title { font-size: 0.86rem; }
  .gb-wings { height: 26px; }
}
