:root {
  --bg: #f5f6f4;
  --fl: #ffffff;
  --fl-2: #eef0ec;
  --text: #1c211d;
  --muted: #5d665f;
  --rand: #dde1db;
  --akzent: #1f5c46;
  --akzent-text: #ffffff;
  --gruen: #2e7d4f;
  --gruen-bg: #e3f2e8;
  --gelb: #8a6200;
  --gelb-bg: #fbf0d4;
  --rot: #b3261e;
  --rot-bg: #fbe4e2;
  --grau-bg: #eceee9;
  --radius: 10px;
  --schatten: 0 1px 2px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513; --fl: #1b1f1c; --fl-2: #232825; --text: #e6e9e5; --muted: #9aa49c; --rand: #2f3531;
    --akzent: #5fb48d; --akzent-text: #0f1a14; --gruen: #7fd1a1; --gruen-bg: #1f3a2a; --gelb: #f0c46a;
    --gelb-bg: #3a3017; --rot: #f2a39d; --rot-bg: #3d1f1d; --grau-bg: #262b27;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.klein { font-size: 13px; }
.fehler { color: var(--rot); min-height: 1.2em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--fl); border: 1px solid var(--rand); border-radius: 8px; padding: 9px 11px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }
button { cursor: pointer; border: 1px solid var(--rand); background: var(--fl); border-radius: 8px; padding: 9px 14px; }
button.primary { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
button.gefahr { background: var(--rot-bg); color: var(--rot); border-color: transparent; }
button.link { border: 0; background: none; color: var(--muted); padding: 6px; }
button:disabled { opacity: .55; cursor: default; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--akzent); color: var(--akzent-text); font-size: 15px;
}

/* Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--fl); border: 1px solid var(--rand); border-radius: 14px;
  padding: 24px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--schatten);
}
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }

/* Gerüst */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--fl);
  border-bottom: 1px solid var(--rand);
}
.topbar .link { margin-left: auto; }
.badge {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--grau-bg);
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}
.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--fl); border-bottom: 1px solid var(--rand); overflow-x: auto; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 11px 12px;
  color: var(--muted); white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--akzent); font-weight: 600; }
.zahl {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--rot); color: #fff; font-size: 12px; font-weight: 700; margin-left: 4px;
}
main { flex: 1; min-height: 0; overflow: auto; }
.tab { padding: 16px; max-width: 1100px; margin: 0 auto; }

/* Chat */
.chat { display: flex; flex-direction: column; height: 100%; padding-bottom: 0; }
.verlauf { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.hinweis-start { margin: auto; text-align: center; max-width: 440px; }
.msg { max-width: min(680px, 88%); padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--akzent); color: var(--akzent-text); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--fl); border: 1px solid var(--rand); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: var(--gelb-bg); color: var(--gelb); font-size: 14px; }
.msg.denkt { color: var(--muted); font-style: italic; }
.eingabe {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rand); background: var(--bg); position: sticky; bottom: 0;
}
.eingabe textarea { flex: 1; resize: none; max-height: 160px; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--rand); border-radius: 8px; background: var(--fl); cursor: pointer; }
.icon-btn.aufnahme { background: var(--rot); border-color: var(--rot); animation: puls 1.2s infinite; }
@keyframes puls { 50% { opacity: .6; } }
.anhaenge { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 99px;
  background: var(--grau-bg);
}
.chip button { border: 0; background: none; padding: 0 2px; color: var(--muted); }

/* Listen, Detail */
.split { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 16px; align-items: start; }
.liste-spalte { display: flex; flex-direction: column; gap: 8px; }
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.liste li button {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; background: var(--fl);
}
.liste li button[aria-current="true"] { border-color: var(--akzent); box-shadow: inset 3px 0 0 var(--akzent); }
.liste .unter { font-size: 13px; color: var(--muted); }
.detail, .karte { background: var(--fl); border: 1px solid var(--rand); border-radius: var(--radius); padding: 16px; box-shadow: var(--schatten); }
.karte { margin-bottom: 16px; }
.reihe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
dl.daten { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.daten dt { color: var(--muted); }
dl.daten dd { margin: 0; }

.tabelle-wrap { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle th, .tabelle td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--rand); vertical-align: top; }
.tabelle th { color: var(--muted); font-weight: 600; font-size: 13px; }

.status { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.status.gut { background: var(--gruen-bg); color: var(--gruen); }
.status.pruefen { background: var(--gelb-bg); color: var(--gelb); }
.status.schlecht { background: var(--rot-bg); color: var(--rot); }
.status.neutral { background: var(--grau-bg); color: var(--muted); }

.freigabe { margin-bottom: 12px; }
.freigabe .kopf { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.freigabe .kopf strong { font-size: 15px; }
.freigabe .aktionen { display: flex; gap: 8px; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); z-index: 10;
}

@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .tab { padding: 12px 16px; }
  .msg { max-width: 92%; }
}
