:root {
  --bg: #f4f5f8;
  --flaeche: #ffffff;
  --flaeche-2: #eef0f5;
  --text: #141a2b;
  --gedaempft: #626b80;
  --linie: #e1e4ec;
  --marke: #14213d;
  --akzent: #f4a63a;
  --akzent-text: #14213d;
  --primaer: #1f4fd6;
  --primaer-text: #ffffff;
  --gut: #1f8a4c;
  --warn: #c2410c;
  --bubble-ich: #1f4fd6;
  --bubble-ich-text: #ffffff;
  --schatten: 0 1px 2px rgba(20, 26, 43, .06), 0 4px 16px rgba(20, 26, 43, .06);
  --radius: 16px;
  --tap: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1220;
    --flaeche: #171c2d;
    --flaeche-2: #20263a;
    --text: #eef0f6;
    --gedaempft: #9aa3b8;
    --linie: #2a3147;
    --primaer: #5b82ff;
    --bubble-ich: #2c55d9;
    --schatten: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1220; --flaeche: #171c2d; --flaeche-2: #20263a; --text: #eef0f6; --gedaempft: #9aa3b8;
  --linie: #2a3147; --primaer: #5b82ff; --bubble-ich: #2c55d9; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 24px; }
h3 { font-size: 16px; font-weight: 650; }
.gedaempft { color: var(--gedaempft); }
.fehler { color: var(--warn); }

/* ---------- Knöpfe */
.knopf {
  font: inherit; font-weight: 600; border: 1px solid var(--linie); background: var(--flaeche);
  color: var(--text); border-radius: 12px; min-height: 44px; padding: 0 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.knopf:active { transform: scale(.97); }
.knopf.primaer { background: var(--primaer); color: var(--primaer-text); border-color: transparent; }
.knopf.gut { background: var(--gut); color: #fff; border-color: transparent; }
.knopf.geist { background: transparent; }
.knopf.gross { min-height: var(--tap); width: 100%; font-size: 18px; }
.knopf.rund { width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0; border-radius: 50%; font-size: 22px; flex: none; }
.knopf:disabled { opacity: .5; }

/* ---------- Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--marke); }
.login-karte {
  width: min(380px, 100%); background: var(--flaeche); border-radius: 24px; padding: 32px 24px;
  display: grid; gap: 14px; text-align: center; box-shadow: var(--schatten);
}
.login-karte input {
  font: inherit; font-size: 18px; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--linie);
  padding: 0 16px; background: var(--flaeche-2); color: var(--text);
}
.logo, .logo-gross {
  background: var(--akzent); color: var(--akzent-text); font-weight: 800; border-radius: 50%;
  display: grid; place-items: center;
}
.logo { width: 38px; height: 38px; font-size: 18px; flex: none; }
.logo-gross { width: 72px; height: 72px; font-size: 34px; margin: 0 auto 6px; }

/* ---------- App-Gerüst */
.app {
  height: 100dvh; display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "kopf" "inhalt" "tabs";
}
.kopf {
  grid-area: kopf; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--marke); color: #fff;
}
.marke { display: flex; align-items: center; gap: 12px; min-width: 0; }
.marke-titel { font-weight: 700; }
.marke-sub { font-size: 13px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-aktionen { display: flex; align-items: center; gap: 10px; }
.kopf .knopf.geist { color: #fff; border-color: rgba(255,255,255,.25); min-height: 38px; }
.status-punkt { width: 10px; height: 10px; border-radius: 50%; background: #888; }
.status-punkt.bereit { background: #34d27a; }
.status-punkt.fehlt { background: #f97316; }

.tabs {
  grid-area: tabs; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--flaeche);
  border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  font: inherit; font-size: 12px; font-weight: 600; background: none; border: 0; color: var(--gedaempft);
  padding: 8px 2px 10px; display: grid; justify-items: center; gap: 2px; cursor: pointer; position: relative;
  min-height: 60px;
}
.tabs button .ico { font-size: 22px; line-height: 1.1; }
.tabs button.aktiv { color: var(--primaer); }
.badge {
  position: absolute; top: 4px; left: calc(50% + 8px); background: var(--warn); color: #fff; font-size: 11px;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px;
}

.inhalt { grid-area: inhalt; overflow: hidden; position: relative; }
.tab { display: none; height: 100%; overflow-y: auto; padding: 20px 16px 32px; }
.tab.aktiv { display: block; }
.tab-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.abschnitt { margin: 28px 0 10px; color: var(--gedaempft); }

/* ---------- Breite Bildschirme: Seitenleiste */
@media (min-width: 900px) {
  .app { grid-template-columns: 112px 1fr; grid-template-rows: auto 1fr; grid-template-areas: "kopf kopf" "tabs inhalt"; }
  .tabs { grid-template-columns: 1fr; grid-auto-rows: min-content; border-top: 0; border-right: 1px solid var(--linie); padding-top: 12px; }
  .tabs button { font-size: 13px; min-height: 76px; }
  .tab { padding: 28px 32px 40px; }
  .tab:not(.chat) > * { max-width: 1100px; }
}

/* ---------- Chat */
.chat.aktiv { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.verlauf { flex: 1; overflow-y: auto; padding: 20px 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.verlauf > * { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
.willkommen { padding: 8vh 4px 0; }
.willkommen h2 { font-size: 30px; margin-bottom: 8px; }
.vorschlaege { display: grid; gap: 10px; margin-top: 22px; }
@media (min-width: 700px) { .vorschlaege { grid-template-columns: 1fr 1fr; } }
.vorschlag {
  font: inherit; text-align: left; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; color: var(--text); box-shadow: var(--schatten); min-height: var(--tap);
}
.vorschlag small { display: block; color: var(--gedaempft); font-size: 13px; margin-bottom: 2px; }

.msg { display: flex; }
.msg.ich { justify-content: flex-end; }
.blase {
  max-width: min(88%, 720px); padding: 12px 16px; border-radius: 18px; background: var(--flaeche);
  box-shadow: var(--schatten); overflow-wrap: anywhere;
}
.msg.ich .blase { background: var(--bubble-ich); color: var(--bubble-ich-text); border-bottom-right-radius: 6px; }
.msg.ki .blase { border-bottom-left-radius: 6px; }
.blase p { margin: 0 0 8px; } .blase p:last-child { margin-bottom: 0; }
.blase ul { margin: 4px 0 8px; padding-left: 20px; } .blase li { margin: 3px 0; }
.blase img { max-width: 160px; border-radius: 10px; display: block; margin-bottom: 8px; }
.aktionen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.aktion {
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--flaeche-2); color: var(--gedaempft);
}
.aktion.schreibt { background: color-mix(in srgb, var(--akzent) 25%, transparent); color: var(--text); }
.denkt .blase { color: var(--gedaempft); display: flex; align-items: center; gap: 10px; }
.punkte span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin: 0 2px; animation: hupf 1.2s infinite; }
.punkte span:nth-child(2) { animation-delay: .15s; } .punkte span:nth-child(3) { animation-delay: .3s; }
@keyframes hupf { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.hinweis-freigabe { margin-top: 10px; }

.eingabe {
  border-top: 1px solid var(--linie); background: var(--flaeche); padding: 10px 12px; flex: none;
}
.eingabe-zeile { display: flex; align-items: flex-end; gap: 8px; max-width: 860px; margin: 0 auto; }
.eingabe textarea {
  flex: 1; font: inherit; font-size: 18px; resize: none; border: 1px solid var(--linie); border-radius: 24px;
  padding: 13px 18px; background: var(--flaeche-2); color: var(--text); min-height: var(--tap); max-height: 40vh;
  outline: none;
}
.eingabe textarea:focus { border-color: var(--primaer); }
#btn-mikro.aufnahme { background: var(--warn); color: #fff; border-color: transparent; animation: puls 1.2s infinite; }
@keyframes puls { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--warn) 25%, transparent); } }
.anhaenge { display: flex; gap: 8px; max-width: 860px; margin: 0 auto 8px; }
.anhang { position: relative; }
.anhang img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.anhang button {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: var(--text); color: var(--bg); cursor: pointer; font-size: 13px;
}

/* ---------- Karten & Listen */
.karte { background: var(--flaeche); border-radius: var(--radius); padding: 18px; box-shadow: var(--schatten); }
.karte h3 { margin-bottom: 10px; }
.raster { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 900px) { .raster { grid-template-columns: 1fr 1fr; } }
.kennzahlen { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .kennzahlen { grid-template-columns: repeat(3, 1fr); } }
.kz { background: var(--flaeche); border-radius: var(--radius); padding: 16px; box-shadow: var(--schatten); }
.kz .wert { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.kz .label { color: var(--gedaempft); font-size: 13px; }
.kz.warn .wert { color: var(--warn); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.liste li:last-child { border-bottom: 0; }
.liste .haupt { flex: 1; min-width: 0; }
.liste .meta { color: var(--gedaempft); font-size: 13px; }
.liste.kompakt li { padding: 8px 0; font-size: 15px; }
.leer { color: var(--gedaempft); padding: 8px 0; }
.check {
  width: 32px; height: 32px; flex: none; border-radius: 50%; border: 2px solid var(--linie); background: none;
  cursor: pointer; color: var(--gut); font-size: 16px;
}
.check:hover { border-color: var(--gut); }
.prio-hoch { color: var(--warn); font-weight: 700; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--flaeche-2); color: var(--gedaempft); }
.pill.gut { background: color-mix(in srgb, var(--gut) 18%, transparent); color: var(--gut); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

/* ---------- Freigaben */
.freigaben { display: grid; gap: 16px; }
@media (min-width: 1100px) { .freigaben { grid-template-columns: 1fr 1fr; } }
.freigabe { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); overflow: hidden; border-top: 4px solid var(--akzent); }
.freigabe .koerper { padding: 16px 18px; }
.freigabe .typ { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--gedaempft); }
.freigabe h3 { margin: 4px 0 10px; font-size: 18px; }
.freigabe pre {
  white-space: pre-wrap; font: inherit; font-size: 15px; background: var(--flaeche-2); padding: 12px; border-radius: 10px;
  margin: 8px 0 0; max-height: 260px; overflow: auto;
}
.zahlen { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-variant-numeric: tabular-nums; font-size: 15px; }
.zahlen .r { text-align: right; } .zahlen .total { font-weight: 750; font-size: 17px; }
.warnliste { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); font-size: 14px; }
.freigabe .fuss { display: flex; gap: 10px; padding: 12px 18px 16px; flex-wrap: wrap; }
.freigabe .fuss .knopf { flex: 1; min-height: var(--tap); }

/* ---------- Ideen */
.ideen { display: grid; gap: 14px; }
@media (min-width: 800px) { .ideen { grid-template-columns: repeat(2, 1fr); } }
.idee { background: var(--flaeche); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--schatten); }
.idee h3 { font-size: 17px; margin-bottom: 6px; }
.idee p { margin: 0 0 8px; }
.idee .schritt { font-size: 14px; color: var(--gedaempft); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Firma / Tabellen */
.segmente { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.segmente button {
  font: inherit; font-weight: 600; font-size: 15px; white-space: nowrap; border: 1px solid var(--linie); background: var(--flaeche);
  color: var(--text); padding: 10px 16px; border-radius: 999px; cursor: pointer; min-height: 44px;
}
.segmente button.aktiv { background: var(--marke); color: #fff; border-color: transparent; }
.tabelle-wrap { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--linie); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--gedaempft); position: sticky; top: 0; background: var(--flaeche); }
td.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.fuss-aktionen { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 50;
  max-width: calc(100% - 32px); box-shadow: var(--schatten);
}
