/* Design 1:1 nach Mocks/api-dashboard-mockup-v5.html,
   ergaenzt um Login, Einstellungen, Detailansicht und Dauerbetrieb. */

:root {
  --bg: #0A0812;
  --ink: #F2EFFB;
  --ink-soft: #8D85AE;
  --ink-faint: #55507A;
  --hairline: rgba(141, 133, 174, 0.16);
  --oa: #FB7185;
  --an: #FBBF24;
  --or: #A78BFA;
  --ds: #7DD3FC;
  --green: #4ADE80;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); }
body {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(109, 40, 217, 0.14), transparent 70%),
    var(--bg);
  color: var(--ink);
  padding: 40px 50px 90px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.frame { max-width: 1180px; margin: 0 auto; }

/* Dauerbetrieb: der gesamte Inhalt wandert unmerklich, damit sich nichts einbrennt. */
.shift { transition: transform 3s linear; will-change: transform; }

/* Kopf */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}
.brand { font-size: 14px; font-weight: 600; letter-spacing: 0.14em; color: var(--ink-soft); }
.head-right { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.9);
  animation: pulse 2.8s ease-in-out infinite;
}
.live.stale i { background: var(--an); box-shadow: 0 0 10px rgba(251, 191, 36, 0.9); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } .shift { transition: none; } }

nav { display: flex; gap: 18px; font-size: 13px; }
nav a, .linkish {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
nav a:hover, .linkish:hover { color: var(--ink); border-bottom-color: var(--hairline); }

.headline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 40px;
  flex-wrap: wrap;
  margin-bottom: 46px;
}
h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 540px;
}
h1 em { font-style: normal; color: var(--oa); }
.totals { text-align: right; }
.totals .value { font-size: 52px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
.totals .label { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.totals .label b { color: var(--ink); font-weight: 600; }

/* Zeitachse */
.ruler {
  position: relative;
  height: 20px;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--ink-faint);
}
.ruler span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.ruler span:first-child { transform: none; }
.ruler span:last-child { transform: translateX(-100%); }

/* Plattform-Bloecke */
.block { padding: 26px 0 24px; position: relative; display: block; color: inherit; text-decoration: none; }
.block + .block::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline) 15%, var(--hairline) 85%, transparent);
}
a.block:hover .b-name b { text-decoration: underline; text-underline-offset: 4px; }
a.block:focus-visible { outline: 2px solid var(--or); outline-offset: 6px; border-radius: 6px; }
.b-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.b-name { display: flex; align-items: baseline; gap: 11px; flex-wrap: wrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; position: relative; top: -1px; }
h1 .swatch { width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; }
.swatch.oa { background: var(--oa); box-shadow: 0 0 8px rgba(251,113,133,.75); }
.swatch.an { background: var(--an); box-shadow: 0 0 8px rgba(251,191,36,.7); }
.swatch.or { background: var(--or); box-shadow: 0 0 8px rgba(167,139,250,.7); }
.swatch.ds { background: var(--ds); box-shadow: 0 0 8px rgba(125,211,252,.65); }
.b-name b { font-size: 17px; font-weight: 700; }
.b-name .state { font-size: 13px; font-weight: 600; margin-left: 2px; }
.state.ok { color: var(--green); }
.state.warn { color: var(--an); }
.state.crit { color: var(--oa); }
.state.wartet { color: var(--ink-soft); }
.b-balance { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.b-balance.pending { font-size: 15px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }

/* Laufzeit-Leiste */
.track {
  position: relative;
  height: 56px;
  background-image:
    linear-gradient(var(--hairline), var(--hairline)),
    linear-gradient(var(--hairline), var(--hairline)),
    linear-gradient(var(--hairline), var(--hairline)),
    linear-gradient(var(--hairline), var(--hairline));
  background-size: 1px 12px, 1px 12px, 1px 12px, 1px 12px;
  background-position: 25% bottom, 50% bottom, 75% bottom, 100% bottom;
  background-repeat: no-repeat;
}
.track .rail {
  position: absolute;
  bottom: 5px; left: 0; right: 0;
  height: 2px;
  background: rgba(141, 133, 174, 0.12);
  border-radius: 999px;
}
.track .fill {
  position: absolute;
  bottom: 2px; left: 0;
  height: 8px;
  border-radius: 999px;
  transition: width 900ms ease;
}
.fill.oa { background: linear-gradient(90deg, rgba(251,113,133,.25), var(--oa)); box-shadow: 0 0 14px rgba(251,113,133,.55); }
.fill.an { background: linear-gradient(90deg, rgba(251,191,36,.25), var(--an)); box-shadow: 0 0 14px rgba(251,191,36,.5); }
.fill.or { background: linear-gradient(90deg, rgba(167,139,250,.25), var(--or)); box-shadow: 0 0 14px rgba(167,139,250,.5); }
.fill.ds { background: linear-gradient(90deg, rgba(125,211,252,.25), var(--ds)); box-shadow: 0 0 14px rgba(125,211,252,.45); }
.track .end {
  position: absolute;
  bottom: 0.5px;
  width: 11px; height: 11px;
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 900ms ease;
}
.end.oa { background: var(--oa); box-shadow: 0 0 12px rgba(251,113,133,1); }
.end.an { background: var(--an); box-shadow: 0 0 12px rgba(251,191,36,.95); }
.end.or { background: var(--or); box-shadow: 0 0 12px rgba(167,139,250,.95); }
.end.ds { background: var(--ds); box-shadow: 0 0 12px rgba(125,211,252,.95); }
.track .days {
  position: absolute;
  top: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(10, 8, 18, 0.92);
  border: 1px solid;
  transition: left 900ms ease;
}
.days.oa { color: var(--oa); border-color: rgba(251,113,133,.4); }
.days.an { color: var(--an); border-color: rgba(251,191,36,.4); }
.days.or { color: var(--or); border-color: rgba(167,139,250,.4); }
.days.ds { color: var(--ds); border-color: rgba(125,211,252,.4); }
.days.wartet { color: var(--ink-soft); border-color: var(--hairline); }
.days small { font-weight: 500; color: var(--ink-soft); font-size: 11.5px; }
.days::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 1px; height: 9px;
  background: currentColor;
  opacity: 0.5;
}
.days.edge::after { left: auto; right: 16px; }

/* Kennwerte mit Vorperioden-Vergleich */
.b-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-top: 20px;
  max-width: 720px;
}
.stat .lbl { font-size: 12.5px; color: var(--ink-soft); }
.stat .val { font-size: 17px; font-weight: 700; margin: 4px 0 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp { display: flex; flex-direction: column; gap: 4px; max-width: 170px; }
.cmp i { display: block; height: 5px; border-radius: 999px; transition: width 900ms ease; }
.cmp .prev { background: rgba(141, 133, 174, 0.30); }
.block.oa .cmp .now { background: var(--oa); box-shadow: 0 0 8px rgba(251,113,133,.45); }
.block.an .cmp .now { background: var(--an); box-shadow: 0 0 8px rgba(251,191,36,.4); }
.block.or .cmp .now { background: var(--or); box-shadow: 0 0 8px rgba(167,139,250,.4); }
.block.ds .cmp .now { background: var(--ds); box-shadow: 0 0 8px rgba(125,211,252,.4); }
.stat .prevtxt { font-size: 11.5px; color: var(--ink-faint); margin-top: 7px; }

.src { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin-top: 18px; }
.src b { color: var(--ink); font-weight: 600; }

/* Abschnitte */
.section-title { margin: 68px 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.section-note { color: var(--ink-soft); font-size: 14px; margin-bottom: 26px; max-width: 640px; line-height: 1.65; }

/* Detail pro Schluessel */
.key-row {
  display: grid;
  grid-template-columns: 230px 1fr 150px;
  gap: 20px;
  align-items: center;
  padding: 16px 0;
  position: relative;
  max-width: 820px;
}
.key-row + .key-row::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline) 15%, var(--hairline) 85%, transparent);
}
.key-name { font-size: 15px; font-weight: 700; }
.key-name span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-top: 3px; }
.key-bar { height: 7px; background: rgba(167, 139, 250, 0.10); border-radius: 999px; overflow: hidden; }
.key-bar div {
  height: 100%;
  background: linear-gradient(90deg, #C4B5FD, #6D28D9);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}
.key-vals { text-align: right; font-size: 12.5px; color: var(--ink-soft); }
.key-vals strong {
  display: block;
  font-size: 16px;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.faint { color: var(--ink-faint); font-size: 12.5px; }

/* Hinweisbaender */
.notice {
  border-left: 2px solid var(--an);
  padding: 10px 0 10px 14px;
  margin: 18px 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.notice.ok { border-color: var(--green); }
.notice.bad { border-color: var(--oa); }
.notice b { color: var(--ink); font-weight: 600; }

/* Formulare */
form.card {
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 26px;
  max-width: 620px;
  background: rgba(19, 16, 34, 0.55);
}
form.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
form.card .hint { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 16px; line-height: 1.6; }
label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; }
label span { display: block; margin-bottom: 6px; }
input, select {
  width: 100%;
  background: rgba(10, 8, 18, 0.75);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--or); }
select option { background: #131022; color: var(--ink); }
button {
  background: var(--ink);
  color: #16121F;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: #fff; }
button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--hairline);
  padding: 8px 14px;
  font-size: 12.5px;
}
button.ghost:hover { color: var(--ink); border-color: var(--ink-soft); background: transparent; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* Schluesselliste in den Einstellungen */
.key-admin { border-top: 1px solid var(--hairline); padding: 14px 0; max-width: 620px; }
.key-admin:first-of-type { border-top: none; }
.key-admin .top { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.key-admin .top b { font-size: 15px; }
.key-admin .meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.6; }
.key-admin form { display: inline; }
.key-admin .actions { display: flex; gap: 8px; }
/* Eingabezeile je Plattform: Feld und Knopf nebeneinander, auf dem Handy untereinander. */
.key-admin form.key-eingabe { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 10px; }
.key-admin form.key-eingabe input { width: 100%; }
@media (max-width: 560px) {
  .key-admin form.key-eingabe { grid-template-columns: 1fr; }
}
.check-ok { color: var(--green); }
.check-bad { color: var(--oa); }

/* Login */
.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 30px; margin: 14px 0 26px; }
.error { color: var(--oa); font-size: 13.5px; margin-bottom: 14px; }

/* Mobil */
@media (max-width: 700px) {
  body { padding: 26px 18px 60px; }
  h1 { font-size: 28px; }
  .headline { margin-bottom: 34px; }
  .totals { text-align: left; }
  .totals .value { font-size: 40px; }
  .b-balance { font-size: 23px; }
  .b-stats { gap: 14px; }
  .stat .val { font-size: 15.5px; }
  .cmp { max-width: none; }
  .section-title { margin: 50px 0 8px; }
  .row-2 { grid-template-columns: 1fr; }
  .key-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name vals" "bar bar";
    gap: 10px 14px;
  }
  .key-name { grid-area: name; }
  .key-vals { grid-area: vals; }
  .key-bar { grid-area: bar; }
}

@media (max-width: 560px) {
  .ruler span.thin { display: none; }
}

@media (max-width: 420px) {
  .b-stats { grid-template-columns: 1fr; gap: 18px; }
  .totals .value { font-size: 34px; }
  h1 { font-size: 24px; }
}
