/* =========================================================================
   Formkurve – Design-System (Schmückstück-Grundgerüst, eigene Farbwelt)
   Helle Bühne mit Petrol-Akzent, dazu eine Dunkelpalette (System-Einstellung
   oder Nutzerwahl per data-theme auf <html>). Ein Akzent, nie als Fließtext;
   die Statusfarben (ok/warn/error) sind die einzige Ausnahme – Ampel-Semantik.
   Schrift: System-Stack, keine Webfonts. Zahlen tabellarisch.
   ========================================================================= */
:root {
  color-scheme: light;
  --brand-bg:        #fbfbfa;
  --brand-surface:   #ffffff;
  --brand-ink:       #22272b;   /* einzige Textfarbe */
  --brand-muted:     #647079;   /* sekundärer Text (4,5:1 auf Weiß) */
  --brand-accent:    #1f6f66;   /* Petrol – Rahmen/Fokus/Grafik, NIE Text */
  --brand-accent-d:  #175750;   /* dunkleres Petrol (Hover) */
  --brand-accent-bg: #e6f2f0;   /* gedämpfte Akzentfläche (Badges, Balken-Spur) */
  --brand-border:    #e6e9ec;
  --brand-input:     #ffffff;
  --radius:          14px;
  --shadow:          0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(34, 39, 43, .06);
  --shadow-hover:    0 10px 32px rgba(34, 39, 43, .12);
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Status (Ampel) */
  --hc-ok:      #2e7d4f;  --hc-ok-bg:      #e8f4ec;
  --hc-warn:    #9a5b00;  --hc-warn-bg:    #fbf1e0;
  --hc-error:   #b8322a;  --hc-error-bg:   #fbeae8;
  --hc-unknown: #647079;  --hc-unknown-bg: #eef1f3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-bg:        #15181b;
    --brand-surface:   #1e2226;
    --brand-ink:       #e9ecef;
    --brand-muted:     #98a2ab;
    --brand-accent:    #4fc3b5;
    --brand-accent-d:  #7ad6cb;
    --brand-accent-bg: #173a37;
    --brand-border:    #2b3137;
    --brand-input:     #15181b;
    --shadow:          0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    --shadow-hover:    0 10px 32px rgba(0, 0, 0, .45);
    --hc-ok:      #5ccf8a;  --hc-ok-bg:      #163626;
    --hc-warn:    #f2b84b;  --hc-warn-bg:    #3a2d10;
    --hc-error:   #ff7b6b;  --hc-error-bg:   #3f1f1b;
    --hc-unknown: #98a2ab;  --hc-unknown-bg: #262b30;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-bg:        #15181b;
  --brand-surface:   #1e2226;
  --brand-ink:       #e9ecef;
  --brand-muted:     #98a2ab;
  --brand-accent:    #4fc3b5;
  --brand-accent-d:  #7ad6cb;
  --brand-accent-bg: #173a37;
  --brand-border:    #2b3137;
  --brand-input:     #15181b;
  --shadow:          0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  --shadow-hover:    0 10px 32px rgba(0, 0, 0, .45);
  --hc-ok:      #5ccf8a;  --hc-ok-bg:      #163626;
  --hc-warn:    #f2b84b;  --hc-warn-bg:    #3a2d10;
  --hc-error:   #ff7b6b;  --hc-error-bg:   #3f1f1b;
  --hc-unknown: #98a2ab;  --hc-unknown-bg: #262b30;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }  /* nie horizontal scrollen */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
  background: var(--brand-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.centered { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
a { color: var(--brand-ink); }

/* --- Marke / Logo (Inline-SVG, färbt sich über currentColor/Variablen) --- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand--stacked { flex-direction: column; gap: 10px; text-align: center; }
.brand__mark { width: 28px; height: 28px; display: block; }
.brand--stacked .brand__mark { width: 56px; height: 56px; }
.brand__name { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; }
.brand--stacked .brand__name { font-size: 1.4rem; }

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  padding: 12px 24px;
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
}
.topbar__back { order: 0; }
.topbar .brand { order: 1; }
.topbar__nav { order: 2; margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 16px; row-gap: 6px; }
.topbar__link { color: var(--brand-muted); text-decoration: none; font-size: .88rem; white-space: nowrap; }
.topbar__logout { display: contents; }
button.topbar__link { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
.topbar__link:hover { color: var(--brand-ink); }
.topbar__user { font-size: .82rem; color: var(--brand-muted); padding: 3px 10px; border-radius: 999px; background: var(--brand-accent-bg); white-space: nowrap; }
.topbar__back {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 7px 12px; border: 1px solid var(--brand-border); border-radius: 10px;
  background: var(--brand-surface); color: var(--brand-ink); text-decoration: none;
  font-size: .88rem; font-weight: 500; white-space: nowrap;
}
.topbar__back:hover { border-color: var(--brand-accent); }
.topbar__back-arrow { font-size: 1.05rem; line-height: 1; }

.bottomnav { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; margin-top: 40px; padding: 16px 24px; border-top: 1px solid var(--brand-border); color: var(--brand-muted); font-size: .8rem; }

/* --- Layout --- */
.layout { max-width: 680px; margin: 28px auto; padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.layout--wide { max-width: 1100px; }
.layout--wide .h1 { margin-top: 4px; }

/* --- Kacheln (App-Übersicht) --- */
.bereich { font-size: .74rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-muted); margin: 8px 0 -8px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 8px; min-height: 140px; padding: 20px;
  background: var(--brand-surface); border: 1px solid var(--brand-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--brand-ink);
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.tile:hover { border-color: var(--brand-accent); box-shadow: var(--shadow-hover); }
.tile:active { transform: translateY(1px); }
.tile__title { font-size: 1.05rem; font-weight: 600; }
.tile__desc { color: var(--brand-muted); font-size: .9rem; line-height: 1.4; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile__cta { align-self: flex-start; margin-top: 4px; font-size: .82rem; font-weight: 600; }
.tile--disabled { border-style: dashed; box-shadow: none; background: transparent; cursor: default; }
.tile--disabled .tile__title, .tile--disabled .tile__desc { color: var(--brand-muted); }
.tile--disabled:hover { border-color: var(--brand-border); box-shadow: none; }

/* --- Karten, Typografie --- */
.card { background: var(--brand-surface); border: 1px solid var(--brand-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.card--narrow { width: 100%; max-width: 380px; }
.card--accent { border-color: var(--brand-accent); }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 6px; letter-spacing: -.01em; }
.h2 { font-size: 1.02rem; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--brand-muted); margin: 0 0 16px; }
.small { font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.row > * { min-width: 0; }
.grow { flex: 1 1 280px; }

/* --- Formulare --- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; grid-column: 1 / -1; min-width: 0; }
.field--small { grid-column: span 1; }
.field__label { font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-muted); }
.field__input {
  font: inherit; font-size: 16px; color: var(--brand-ink);
  width: 100%; min-width: 0; padding: 10px 12px;
  border: 1px solid var(--brand-border); border-radius: 10px; background: var(--brand-input);
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 3px var(--brand-accent-bg); }
select.field__input { appearance: none; -webkit-appearance: none; height: 44px; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23647079' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; }
textarea.field__input { resize: vertical; min-height: 72px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-accent); cursor: pointer; }
.radios { display: flex; flex-wrap: wrap; gap: 14px 22px; }

/* Standard-Button: leiser Umriss (keine gefüllten CTAs). */
.btn {
  grid-column: 1 / -1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: .95rem; font-weight: 500; color: var(--brand-ink);
  background: var(--brand-surface); border: 1px solid var(--brand-border); border-radius: 10px;
  min-height: 42px; padding: 9px 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: border-color .15s, background .15s, transform .02s;
}
.btn:hover { border-color: var(--brand-accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--accent { border-color: var(--brand-accent); }
.btn--ghost { background: var(--brand-accent-bg); border-color: transparent; }
.btn--inline { grid-column: auto; min-height: 36px; padding: 6px 12px; font-size: .86rem; }
.btn--danger { color: var(--hc-error); border-color: var(--hc-error); }
.btn--danger:hover { background: var(--hc-error-bg); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; grid-column: 1 / -1; }

/* --- Status / Alerts / Badges --- */
.status { margin-top: 14px; font-size: .92rem; }
.status--info { color: var(--brand-muted); }
.status--error { color: var(--hc-error); }
.alert { margin: 4px 0 0; font-size: .88rem; grid-column: 1 / -1; }
.alert--error { color: var(--hc-error); }
.hinweis { padding: 10px 14px; border-radius: 10px; border-left: 4px solid var(--brand-accent); background: var(--brand-accent-bg); font-size: .92rem; }
.hinweis a { text-decoration: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--brand-border); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-muted); flex: 0 0 auto; }
.badge--ok::before { background: var(--hc-ok); }
.badge--warn::before { background: var(--hc-warn); }
.badge--error::before { background: var(--hc-error); }
.badge--plain::before { display: none; }

/* --- Listen (Schlüssel/Wert-Zeilen) --- */
.liste { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.liste > li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--brand-border); font-size: .95rem; flex-wrap: wrap; align-items: center; }
.liste > li:first-child { border-top: 0; }
.liste__right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- KPI-Boxen --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { background: var(--brand-surface); border: 1px solid var(--brand-border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi__label { font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-muted); }
.kpi__num { font-size: 1.7rem; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; line-height: 1.1; }
.kpi__sub { color: var(--brand-muted); font-size: .82rem; margin-top: 4px; }

/* --- Karte „Zu erledigen" --- */
.aufgaben { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.aufgabe { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--brand-border); font-size: .92rem; text-decoration: none; color: inherit; }
.aufgabe:hover { border-color: var(--brand-accent); }
.aufgabe__anzahl { min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; font-size: .78rem; font-weight: 600; background: var(--hc-warn-bg); color: var(--hc-warn); }
.aufgabe--error .aufgabe__anzahl { background: var(--hc-error-bg); color: var(--hc-error); }
.aufgabe__text { flex: 1; min-width: 0; }

/* --- Fortschrittsbalken --- */
.bar { height: 8px; border-radius: 999px; background: var(--brand-accent-bg); overflow: hidden; }
.bar__fill { height: 100%; background: var(--brand-accent); border-radius: 999px; transition: width .35s ease; }

/* --- Tabellen --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--brand-border); vertical-align: top; }
.table th { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-muted); }
.table .num { text-align: right; white-space: nowrap; }
.ab-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ab-table th, .ab-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--brand-border); vertical-align: top; }
.ab-table th { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-muted); }

/* --- Chat (Coach) --- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.chat__msg { max-width: 720px; padding: 12px 16px; border-radius: var(--radius); font-size: .95rem; line-height: 1.5; }
.chat__msg--user { align-self: flex-end; background: var(--brand-accent-bg); border: 1px solid var(--brand-border); }
.chat__msg--coach { align-self: flex-start; background: var(--brand-surface); border: 1px solid var(--brand-border); }

/* =========================================================================
   Health Check – Dashboard (Statusfarben = Funktion, nicht Dekoration)
   ========================================================================= */
.hc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hc-head__right { display: flex; align-items: center; gap: 14px; }
.hc-refresh { grid-column: auto; width: auto; }
.hc-overall { font-size: .82rem; font-weight: 600; letter-spacing: .04em; padding: 6px 14px; border-radius: 999px; white-space: nowrap; }
.hc-overall--ok { color: var(--hc-ok); background: var(--hc-ok-bg); }
.hc-overall--warn { color: var(--hc-warn); background: var(--hc-warn-bg); }
.hc-overall--error { color: var(--hc-error); background: var(--hc-error-bg); }
.hc-overall--unknown { color: var(--hc-unknown); background: var(--hc-unknown-bg); }
.hc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 8px; }
.hc-card { background: var(--brand-surface); border: 1px solid var(--brand-border); border-left: 4px solid var(--brand-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.hc-card--ok { border-left-color: var(--hc-ok); }
.hc-card--warn { border-left-color: var(--hc-warn); }
.hc-card--error { border-left-color: var(--hc-error); }
.hc-card--unknown { border-left-color: var(--hc-unknown); }
.hc-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hc-card__title { font-size: 1.1rem; font-weight: 600; }
.hc-card__summary { color: var(--brand-muted); font-size: .9rem; margin: 0; }
.hc-badge { font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.hc-badge--ok { color: var(--hc-ok); background: var(--hc-ok-bg); }
.hc-badge--warn { color: var(--hc-warn); background: var(--hc-warn-bg); }
.hc-badge--error { color: var(--hc-error); background: var(--hc-error-bg); }
.hc-badge--unknown { color: var(--hc-unknown); background: var(--hc-unknown-bg); }
.hc-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hc-metric { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--brand-border); border-radius: 10px; min-width: 0; }
.hc-metric__label { font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; overflow-wrap: anywhere; }
.hc-metric__value { font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.hc-metric__sub { font-size: .76rem; color: var(--brand-muted); }
.hc-notes { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.hc-notes li { font-size: .84rem; color: var(--hc-error); }
.hc-card--warn .hc-notes li { color: var(--hc-warn); }
.hc-card--unknown .hc-notes li, .hc-card--ok .hc-notes li { color: var(--brand-muted); }
.hc-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 2px; }
.hc-link { font-size: .8rem; font-weight: 600; text-decoration: none; }
.hc-link:hover { text-decoration: underline; }
.hc-stamp { margin-top: 20px; font-size: .8rem; text-align: right; }

/* --- Admin --- */
.adm-apps { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-tag { font-size: .76rem; background: var(--brand-accent-bg); border-radius: 999px; padding: 2px 9px; }
.adm-role { font-size: .72rem; font-weight: 600; text-transform: uppercase; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--brand-border); }
.adm-role--admin { border-color: var(--brand-accent); }
.adm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 4px; }
.adm-check { display: inline-flex; align-items: center; gap: 7px; }
.adm-check input { width: 17px; height: 17px; accent-color: var(--brand-accent); }
.adm-roleopts { display: flex; gap: 18px; }
.adm-formhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

/* --- 2FA-Einrichtung --- */
.tf-qr { display: block; margin: 10px auto; width: 210px; height: 210px; image-rendering: pixelated; border: 1px solid var(--brand-border); border-radius: 8px; background: #fff; }
.tf-secret { display: block; text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: .95rem; letter-spacing: .08em; background: var(--brand-accent-bg); padding: 8px 10px; border-radius: 8px; margin: 6px 0 14px; user-select: all; -webkit-user-select: all; }
.tf-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; font-family: ui-monospace, Menlo, monospace; font-size: 1.02rem; background: var(--brand-accent-bg); padding: 14px 16px; border-radius: 8px; margin: 10px 0; }
.tf-note { font-size: .88rem; color: var(--brand-muted); }

/* --- Responsiv --- */
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn--inline, .adm-tag a { min-height: 38px; }
}
@media (max-width: 480px) {
  .card { padding: 18px; }
  .layout { margin: 16px auto; padding: 0 16px; gap: 16px; }
  .form { grid-template-columns: 1fr; }
  .field--small { grid-column: 1 / -1; }
  .tiles { grid-template-columns: 1fr; }
  .hc-grid { grid-template-columns: 1fr; }
  .hc-metrics { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; row-gap: 8px; }
  .topbar__nav { flex-wrap: nowrap; gap: 10px; min-width: 0; }
  .topbar__user { font-size: .76rem; padding: 2px 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44vw; }
  .topbar__link { font-size: .8rem; }
  .topbar::after { content: ''; order: 3; flex-basis: 100%; height: 0; }
  .topbar__back { order: 4; padding: 7px 11px; gap: 0; }
  .topbar__back-label { display: none; }
  .bottomnav { padding: 14px 16px; margin-top: 28px; }
}
.btn, .tile, .topbar__link, .aufgabe { -webkit-tap-highlight-color: transparent; }
