:root {
  --bg: #ffffff;
  --bg-side: #f9f9f9;
  --bg-hover: #ececec;
  --bg-soft: #f4f4f4;
  --bd: #e5e5e5;
  --tx: #0d0d0d;
  --tx2: #5d5d5d;
  --tx3: #8e8e8e;
  --btn: #0d0d0d;
  --btn-tx: #ffffff;
  --ok: #15803d;
  --ok-bg: #f1faf4;
  --ok-bd: #cdebd7;
  --err: #dc2626;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --bg-side: #171717;
    --bg-hover: #2b2b2b;
    --bg-soft: #2f2f2f;
    --bd: #343434;
    --tx: #ececec;
    --tx2: #b4b4b4;
    --tx3: #8a8a8a;
    --btn: #ececec;
    --btn-tx: #0d0d0d;
    --ok: #4ade80;
    --ok-bg: #18271e;
    --ok-bd: #25422f;
    --err: #f87171;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--tx);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--tx2); }
.faint { color: var(--tx3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
svg { flex: none; }

/* Buttons & Felder */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--bd);
  background: transparent; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--btn); color: var(--btn-tx); border-color: var(--btn); }
.btn.primary:hover { opacity: 0.85; background: var(--btn); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer; color: var(--tx2);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--tx); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--tx2); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--bd);
  background: var(--bg-soft); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--tx3); }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e8e' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--btn); }
.err { color: var(--err); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

/* Anmeldung / Einrichtung */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 380px; }
.card.wide-card { max-width: 560px; }
.brand { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand i { width: 20px; height: 20px; border-radius: 6px; background: var(--btn); display: inline-grid; place-items: center; color: var(--btn-tx); }
.card h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 28px 0 20px; }
.card .sub { margin: -12px 0 20px; color: var(--tx2); }
.card .section > h2 { display: none; }
.stepper { color: var(--tx3); font-size: 13px; margin-top: 28px; }
.actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }

/* Rahmen */
.shell { display: flex; height: 100%; }
.sidebar {
  width: 260px; flex: none; background: var(--bg-side); display: flex; flex-direction: column;
  border-right: 1px solid var(--bd); padding: 10px 8px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 10px; }
.side-new {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left;
}
a.side-new { text-decoration: none; }
.side-new:hover, .hist a:hover, .hist a.on { background: var(--bg-hover); }
.hist { flex: 1; overflow-y: auto; margin-top: 10px; }
.hist h3 { font-size: 11px; font-weight: 500; color: var(--tx3); padding: 14px 10px 4px; }
.hist a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px;
  text-decoration: none; position: relative;
}
.hist a span.t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist a button { display: none; }
.hist a:hover button { display: grid; }
.hist .empty { padding: 14px 10px; color: var(--tx3); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.running { border: 1.5px solid var(--tx3); border-top-color: transparent; animation: spin 0.8s linear infinite; width: 10px; height: 10px; }
.dot.error { background: var(--err); }
.me { position: relative; border-top: 1px solid var(--bd); padding-top: 8px; margin-top: 8px; }
.me > button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: left; }
.me > button:hover { background: var(--bg-hover); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--btn); color: var(--btn-tx); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.me .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; bottom: 52px; left: 0; right: 0; background: var(--bg); border: 1px solid var(--bd);
  border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 20;
}
.menu a, .menu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-decoration: none; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--bg-hover); }
.menu hr { border: 0; border-top: 1px solid var(--bd); margin: 6px 0; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--bd); }
#view { flex: 1; overflow-y: auto; }
.scrim { display: none; }

.page { max-width: 920px; margin: 0 auto; padding: 32px 28px 80px; }
.page > h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 24px; }
.section { margin-bottom: 36px; }
.section > h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.section > .sub { color: var(--tx2); margin-bottom: 14px; }
.list { border: 1px solid var(--bd); border-radius: 14px; }
.list > div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.list > div + div { border-top: 1px solid var(--bd); }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--tx2); }
.pill.warn { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) { .pill.warn { background: #3a2f12; color: #fcd34d; } }
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--bd); }
.tabs button { padding: 8px 12px; border: 0; background: transparent; color: var(--tx2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--tx); border-color: var(--tx); }
.form { max-width: 520px; }
.hint { color: var(--tx3); font-size: 12.5px; margin-top: 6px; }
.panel { border: 1px solid var(--bd); border-radius: 14px; padding: 16px; margin-top: 12px; }

/* Startseite */
.home { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 20px 12vh; }
.home h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 22px; text-align: center; }
.prompt { width: 100%; max-width: 720px; background: var(--bg-soft); border: 1px solid var(--bd); border-radius: 24px; padding: 14px 14px 10px 18px; }
.prompt:focus-within { border-color: var(--tx3); }
.prompt textarea { border: 0; background: transparent; padding: 4px 0; resize: none; min-height: 56px; max-height: 240px; border-radius: 0; }
.prompt .bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.prompt select { width: auto; height: 30px; padding: 0 28px 0 10px; border-radius: 999px; background-color: transparent; font-size: 13px; color: var(--tx2); }
.home .meta { margin-top: 14px; color: var(--tx3); font-size: 13px; text-align: center; }
.home .meta a { color: var(--tx2); }

/* Analyse */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; overflow-wrap: anywhere; }
.head .acts { display: flex; gap: 8px; flex: none; }
.meta-line { color: var(--tx2); margin-bottom: 24px; }
.busy { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 90px 0; text-align: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bd); border-top-color: var(--tx); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.best { border: 1px solid var(--ok-bd); background: var(--ok-bg); border-radius: 16px; padding: 18px 20px; margin-bottom: 20px; }
.best .label { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.best h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin: 14px 0; }
.facts dt { color: var(--tx2); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.summary { margin-bottom: 20px; color: var(--tx); max-width: 75ch; }
.warns { margin: 0 0 20px; padding: 0; list-style: none; color: var(--tx2); font-size: 13px; }
.warns li { padding-left: 16px; position: relative; }
.warns li::before { content: "!"; position: absolute; left: 0; font-weight: 700; color: var(--tx3); }

.table-wrap { overflow-x: auto; border: 1px solid var(--bd); border-radius: 14px; margin-bottom: 40px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--tx2); padding: 10px 14px; border-bottom: 1px solid var(--bd); cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; }
th:hover { color: var(--tx); }
td { padding: 11px 14px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
td select { width: auto; padding-top: 6px; padding-bottom: 6px; }
tr:last-child td, tr.detail:last-child td { border-bottom: 0; }
tr.main { cursor: pointer; }
tr.main:hover td { background: var(--bg-soft); }
tr.best-row td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
tr.out td { color: var(--tx3); }
tr.detail td { background: var(--bg-soft); white-space: normal; padding: 16px 18px; }
tr.detail[hidden] { display: none; }
.cell-sub { color: var(--tx3); font-size: 12px; }
.money { min-width: 120px; }
.money b { font-weight: 600; }
.meter { height: 3px; border-radius: 3px; background: var(--bd); margin-top: 5px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--tx3); border-radius: 3px; }
.best-row .meter i { background: var(--ok); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.detail-grid h4 { margin: 0 0 2px; font-size: 12px; font-weight: 500; color: var(--tx3); }
.detail-grid p { overflow-wrap: anywhere; }

/* Chat */
.chat { max-width: 720px; }
.msg { margin-bottom: 18px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user div { background: var(--bg-soft); padding: 8px 14px; border-radius: 18px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { overflow-wrap: anywhere; }
.msg.bot p + p, .msg.bot ul { margin-top: 8px; }
.msg.bot ul { padding-left: 20px; margin-bottom: 0; }
.msg.typing { color: var(--tx3); }
.ask { display: flex; align-items: flex-end; gap: 8px; background: var(--bg-soft); border: 1px solid var(--bd); border-radius: 22px; padding: 8px 8px 8px 16px; }
.ask:focus-within { border-color: var(--tx3); }
.ask textarea { border: 0; background: transparent; padding: 6px 0; resize: none; max-height: 160px; min-height: 28px; border-radius: 0; }
.send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--btn); color: var(--btn-tx); display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { opacity: 0.3; cursor: default; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--btn); color: var(--btn-tx); padding: 10px 16px; border-radius: 999px; transition: 0.2s; z-index: 50;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform 0.2s; width: 280px; }
  .shell.open .sidebar { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 25; }
  .topbar { display: flex; }
  .page { padding: 20px 16px 60px; }
  .head { flex-direction: column; }
  .row { flex-direction: column; }
}

/* Anbieter-Kacheln */
.providers { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.tile {
  flex: 1 1 0; min-width: 96px; max-width: 170px; height: 120px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; border: 1px solid var(--bd); border-radius: 18px;
  background: transparent; cursor: pointer; font-size: 15px; font-weight: 500;
}
.tile:hover { background: var(--bg-hover); border-color: var(--tx3); }
.btn.skip { border: 0; height: auto; padding: 4px 8px; font-size: 13px; color: var(--tx3); }
.btn.skip:hover { background: transparent; color: var(--tx2); text-decoration: underline; }
.tile > span { display: flex; align-items: center; height: 40px; }
.card .section > .sub { text-align: center; }
.card .err { margin-bottom: 14px; }
