/* =========================================================================
   Resydict Immobilien-Lotse — Design-System
   Dark-first, mit hellem Modus. Keine externen Abhängigkeiten.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* Farb-Tokens (Dark) */
  --bg:            #0b1120;
  --bg-soft:       #0f172a;
  --surface:       #131c31;
  --surface-2:     #1b2541;
  --surface-3:     #243150;
  --border:        #25304d;
  --border-soft:   #1c2640;

  --text:          #e8edf7;
  --text-soft:     #aeb9d2;
  --text-dim:      #7c89a8;

  --brand:         #38bdf8;
  --brand-strong:  #0ea5e9;
  --brand-deep:    #0369a1;
  --accent:        #38bdf8;
  /* Vom Akzent abgeleitet (theme.js überschreibt zur Laufzeit) – Fallback hier: */
  --brand-contrast: #06121f;
  --brand-soft:    rgba(56,189,248,.15);
  --brand-glow:    rgba(56,189,248,.5);
  --brand-ink:     #38bdf8;   /* Akzent als Text (Links/Eyebrow); theme.js bringt ihn auf Mindestkontrast */
  --mint:          #34d399;
  --amber:         #fbbf24;
  --rose:          #fb7185;

  --good:          #34d399;
  --warn:          #fbbf24;
  --bad:           #fb7185;

  --ring: 0 0 0 3px rgba(56, 189, 248, .35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 10px 30px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 60px -24px rgba(0,0,0,.7);

  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  --maxw: 1180px;
  --nav-w: 248px;

  --grad-brand: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #a78bfa 100%);
  --grad-warm:  linear-gradient(135deg, #fbbf24 0%, #fb7185 100%);
  --grad-mint:  linear-gradient(135deg, #34d399 0%, #38bdf8 100%);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:            #eef2f9;
  --bg-soft:       #e7edf7;
  --surface:       #ffffff;
  --surface-2:     #f4f7fc;
  --surface-3:     #e9eef7;
  --border:        #d7deea;
  --border-soft:   #e4e9f2;
  --text:          #0f1b33;
  --text-soft:     #44506b;
  --text-dim:      #6b7894;
  --shadow:    0 10px 30px -16px rgba(20,40,80,.28);
  --shadow-lg: 0 30px 60px -28px rgba(20,40,80,.30);
}

/* ----------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  /* atmosphärisches Hintergrund-Glühen */
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -8%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 60%),
    radial-gradient(800px 500px at 8% 4%, rgba(167,139,250,.13), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(52,211,153,.08), transparent 60%);
}
:root[data-theme="light"] body::before { opacity: .6; }

img, svg { display: block; max-width: 100%; }
.ic { width: 20px; height: 20px; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.18; font-weight: 700; letter-spacing: -.015em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--brand-strong); color: var(--brand-contrast); padding: .6rem 1rem; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

/* ----------------------------------------------------------------- Layout */
#app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  display: flex; flex-direction: column; padding: 1.1rem .9rem 0;
  overflow-y: auto;
}
/* „Dunkel"-Schalter unten in einer 48px-Leiste – fluchtet mit der Fußzeile rechts. */
#themebtn { min-height: 48px; font-size: .85rem; }
.brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .5rem 1.1rem; }
.brand__logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--grad-brand); display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--brand-glow);
}
.brand__logo svg { width: 22px; height: 22px; }
.brand__logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 11px; }
.brand__logo--img { background: none; box-shadow: none; }
.brand__name { font-weight: 800; letter-spacing: -.02em; font-size: 1.05rem; }
.brand__sub { font-size: .72rem; color: var(--text-dim); letter-spacing: .14em; text-transform: uppercase; }

/* Account-Menü (oben rechts) */
.acct { position: relative; }
.acct__btn { display: inline-flex; align-items: center; gap: .4rem; }
.acct__menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; z-index: 60;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: .35rem; display: none; box-shadow: 0 18px 40px -12px rgba(0,0,0,.55);
}
.acct.open .acct__menu { display: block; }
.acct__menu a, .acct__menu button {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  padding: .55rem .6rem; border-radius: 9px; background: none; border: 0; cursor: pointer;
  color: var(--text); font: inherit; text-decoration: none;
}
.acct__menu a:hover, .acct__menu button:hover { background: var(--surface-3); }
.acct__menu .acct__sep { height: 1px; background: var(--border); margin: .3rem .2rem; }
.acct__head { padding: .5rem .6rem .2rem; }
.acct__head b { display: block; font-size: .92rem; }
.acct__head span { font-size: .76rem; color: var(--text-dim); }

.legal-doc { line-height: 1.6; }
.legal-doc h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
.legal-doc h2 { font-size: 1.1rem; margin: 1.1rem 0 .4rem; }
.legal-doc p { margin: .5rem 0; color: var(--text-soft); }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: .3rem; }
.nav__group { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; padding: .9rem .6rem .3rem; }
.nav__group:first-child { padding-top: .2rem; }
.nav__item {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .7rem; border-radius: 11px; color: var(--text-soft);
  font-weight: 600; font-size: .94rem; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s; text-align: left; width: 100%;
  background: none;
}
.nav__item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav__item .ic { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav__item--active {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
  box-shadow: inset 3px 0 0 0 var(--brand);
}
.nav__spacer { flex: 1; }
/* Zähler-Badge in der Navigation (z. B. fällige Termine) */
.navbadge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--brand); color: var(--brand-contrast, #fff);
  font-size: .7rem; font-weight: 700; line-height: 1;
}
.nav__foot { font-size: .74rem; color: var(--text-dim); padding: .6rem .7rem; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .8rem;
  padding: .8rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border-soft);
}
.topbar__title { font-size: 1.02rem; font-weight: 700; }
.topbar__crumb { color: var(--text-dim); font-size: .8rem; }
.topbar__spacer { flex: 1; }
/* Auf Desktop steht der Seitentitel bereits als Überschrift auf der Seite – in der
   Topbar wäre er doppelt. Auf Mobil (ohne Sidebar) bleibt er zur Orientierung. */
@media (min-width: 921px) { .topbar__title { display: none; } }
/* Einklappbares Hinweis-/Erinnerungs-Panel (Portfolio): Übersicht bleibt oben dominant. */
.hints-sum { cursor: pointer; display: flex; align-items: center; gap: .55rem; list-style: none; user-select: none; border-radius: 10px; padding: .15rem .25rem; margin: -.15rem -.25rem; }
.hints-sum:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.hints-sum::-webkit-details-marker { display: none; }
.hints-caret { color: var(--brand-ink, var(--brand)); font-size: 1.15rem; line-height: 1; transition: transform .15s ease; flex: none; }
details[open] > .hints-sum .hints-caret { transform: rotate(90deg); }
.hints-toggle-hint { margin-left: auto; font-size: .76rem; color: var(--text-dim); white-space: nowrap; }

/* In-App-Monatskalender (Termine) */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.cal-title { font-size: 1.02rem; min-width: 9.5rem; text-align: center; }
.cal-grid { display: grid; grid-template-columns: 2.2rem repeat(7, 1fr); gap: 6px; }
.cal-wd { text-align: center; font-size: .74rem; color: var(--text-dim); font-weight: 600; padding: .2rem 0; }
.cal-kw { display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--text-dim); }
.cal-day { min-height: 64px; border: 1px solid var(--border-soft); border-radius: 10px; padding: .3rem .35rem; display: flex; flex-direction: column; gap: .25rem; }
.cal-day--out { opacity: .4; }
.cal-day--today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-day--has { cursor: pointer; }
.cal-day--has:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.cal-day--sel { outline: 2px solid var(--brand); outline-offset: -1px; }
.cal-day__n { font-size: .82rem; font-weight: 600; }
.cal-day--out .cal-day__n { font-weight: 400; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-dot--urgent { background: #e11d48; }
.cal-dot--warn { background: #f59e0b; }
.cal-dot--info { background: var(--brand); }
.cal-detail { margin-top: .9rem; border-top: 1px solid var(--border-soft); padding-top: .8rem; }
@media (max-width: 600px) { .cal-day { min-height: 48px; } .cal-title { min-width: 6.5rem; font-size: .92rem; } }

.main { padding: clamp(1.1rem, 3vw, 2.2rem); max-width: var(--maxw); width: 100%; margin: 0 auto; flex: 1; }

.appfoot {
  border-top: 1px solid var(--border-soft);
  padding: 1rem clamp(1rem, 3vw, 2rem);
  max-width: var(--maxw); width: 100%; margin: 0 auto;
  display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; justify-content: space-between;
  font-size: .85rem; color: var(--text-dim); line-height: 1.4;
}
.appfoot__links { white-space: nowrap; }
/* Fußzeile einheitlich gedämpft; Akzent nur beim Hover (keine bunten Misch-Farben). */
.appfoot a { color: var(--text-dim); text-decoration: none; }
.appfoot a:hover { color: var(--brand-ink); text-decoration: underline; }
@media (max-width: 920px) { .appfoot { margin-bottom: 5rem; } }
/* Desktop: Fußzeile mit Rechtshinweis bleibt als schmale Leiste immer sichtbar
   (sticky am unteren Rand). Auf Mobil NICHT sticky, sonst Überlappung mit der
   unteren Navigationsleiste (botnav). */
@media (min-width: 921px) {
  .appfoot {
    position: sticky; bottom: 0; z-index: 25;
    max-width: none; margin: 0;
    min-height: 48px; padding: 0 clamp(1rem, 3vw, 2rem);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(10px) saturate(140%);
  }
}
section.view { animation: rise .4s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- Bits */
.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: var(--brand-ink); font-weight: 700; }
.muted { color: var(--text-soft); }
.dim { color: var(--text-dim); }
.lead { font-size: 1.08rem; color: var(--text-soft); }
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.right { margin-left: auto; }
.grid { display: grid; gap: 1rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.25rem; box-shadow: var(--shadow-sm);
}
.card--pad-lg { padding: 1.5rem 1.6rem; }
.card--glass { background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(8px); }
.card h3 { margin-bottom: .2rem; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
}
.pill--brand { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: color-mix(in srgb, var(--brand) 65%, var(--text)); }
.pill--mint  { background: rgba(52,211,153,.14); border-color: rgba(52,211,153,.4); color: #a7f3d0; }
.pill--amber { background: rgba(251,191,36,.14); border-color: rgba(251,191,36,.4); color: #fde68a; }
.pill--rose  { background: rgba(251,113,133,.14); border-color: rgba(251,113,133,.4); color: #fecdd3; }

.tag { font-size: .72rem; color: var(--text-dim); background: var(--surface-2); border:1px solid var(--border-soft); padding: .15rem .5rem; border-radius: 7px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.05rem; border-radius: 12px; font-weight: 700; font-size: .94rem;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  user-select: none; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary { background: var(--grad-brand); border: none; color: var(--brand-contrast); box-shadow: 0 12px 28px -12px var(--brand-glow); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: transparent; }
.btn--sm { padding: .42rem .72rem; font-size: .84rem; border-radius: 10px; }
.btn--lg { padding: .9rem 1.4rem; font-size: 1.02rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 18px; height: 18px; }

.iconbtn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--text-soft);
}
.iconbtn:hover { color: var(--text); background: var(--surface-3); }
.iconbtn .ic { width: 20px; height: 20px; }

/* Form controls */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > label { font-size: .85rem; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: .76rem; color: var(--text-dim); }
.input, select.input, textarea.input {
  width: 100%; padding: .68rem .8rem; border-radius: 11px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.input--money { font-variant-numeric: tabular-nums; }
.inputgroup { display: flex; align-items: stretch; }
.inputgroup .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.inputgroup .suffix {
  display: grid; place-items: center; padding: 0 .8rem; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border); border-left: none;
  border-top-right-radius: 11px; border-bottom-right-radius: 11px; font-weight: 600; font-size: .9rem;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: var(--surface-3); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad-brand); border: 3px solid var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,.5); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--brand); border: 3px solid var(--bg); cursor: grab;
}

/* Segmented control */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border:1px solid var(--border); border-radius: 13px; flex-wrap: wrap; }
.seg__btn {
  padding: .5rem .85rem; border-radius: 10px; border: none; background: transparent;
  color: var(--text-soft); font-weight: 600; cursor: pointer; font-size: .88rem;
}
.seg__btn--active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* Choice cards */
.choices { display: grid; gap: .7rem; }
.choice {
  display: flex; gap: .9rem; align-items: flex-start; text-align: left; width: 100%;
  padding: 1rem 1.1rem; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); transition: border-color .15s, transform .08s, background .15s;
}
.choice:hover { border-color: var(--brand); background: var(--surface-2); }
.choice:active { transform: translateY(1px); }
.choice--active { border-color: var(--brand); box-shadow: var(--ring); }
.choice__ic { width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.choice__ic .ic { width: 22px; height: 22px; color: var(--brand-ink); }
.choice__title { display: block; font-weight: 700; line-height: 1.3; }
.choice__desc { display: block; margin-top: .15rem; font-size: .85rem; color: var(--text-soft); line-height: 1.4; }

/* Stat / metric */
.metric { display: flex; flex-direction: column; gap: .2rem; }
.metric__label { font-size: .8rem; color: var(--text-dim); font-weight: 600; }
.metric__value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric__value--lg { font-size: 2.3rem; }
.metric__sub { font-size: .8rem; color: var(--text-soft); }
.metric--good .metric__value { color: var(--good); }
.metric--bad .metric__value { color: var(--bad); }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px dashed var(--border-soft); }
.kv:last-child { border-bottom: none; }
.kv__k { color: var(--text-soft); }
.kv__v { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv--total { border-top: 2px solid var(--border); margin-top: .3rem; padding-top: .7rem; }
.kv--total .kv__k { color: var(--text); font-weight: 700; }
.kv--total .kv__v { font-size: 1.15rem; color: var(--brand-ink); }

/* Progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width .5s cubic-bezier(.2,.7,.2,1); }

.bar-track { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar-track > span { height: 100%; }

/* Callout */
.callout { border-radius: var(--radius); padding: 1rem 1.1rem; border: 1px solid var(--border); background: var(--surface-2); display: flex; gap: .8rem; }
.callout .ic { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.callout--info  { border-color: color-mix(in srgb, var(--brand) 35%, transparent); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.callout--good  { border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.callout--warn  { border-color: rgba(251,191,36,.35);  background: rgba(251,191,36,.08); }
.callout--bad   { border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.08); }
.callout__title { font-weight: 700; margin-bottom: .15rem; }

/* Hero */
.hero { position: relative; border-radius: var(--radius-lg); padding: clamp(1.6rem, 4vw, 3rem); overflow: hidden;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 55%),
              radial-gradient(120% 140% at 100% 20%, rgba(167,139,250,.18), transparent 55%),
              linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border); }
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 3rem); }
.hero .lead { max-width: 60ch; margin-top: .8rem; }
.hero__grid { position:absolute; inset:0; opacity:.4; pointer-events:none;
  background-image: linear-gradient(var(--border-soft) 1px, transparent 1px), linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: radial-gradient(70% 70% at 80% 0%, #000, transparent 70%); }

/* Chat */
.chat { display: flex; flex-direction: column; gap: .9rem; }
.msg { display: flex; gap: .7rem; max-width: 100%; }
.msg__avatar { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-2); border:1px solid var(--border); }
.msg__bubble { padding: .8rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); max-width: 78%; }
.msg--user { flex-direction: row-reverse; }
.msg--user .msg__bubble { background: var(--grad-brand); color: var(--brand-contrast); border: none; }
.msg--user .msg__avatar { background: var(--brand-deep); }
.msg__bubble p + p { margin-top: .5rem; }
.typing span { display:inline-block; width:7px; height:7px; margin:0 1px; border-radius:50%; background: var(--text-dim); animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay:.2s } .typing span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,60%,100%{ opacity:.25 } 30%{ opacity:1 } }
.suggests { display:flex; gap:.5rem; flex-wrap:wrap; }
.composer { display:flex; gap:.6rem; align-items:flex-end; }
.composer textarea { resize: none; max-height: 140px; }

/* Accordion / knowledge */
.acc { border:1px solid var(--border); border-radius: var(--radius); overflow:hidden; background: var(--surface); }
.acc + .acc { margin-top: .7rem; }
.acc__head { display:flex; align-items:center; gap:.7rem; width:100%; padding: 1rem 1.1rem; background:none; border:none; cursor:pointer; text-align:left; color:var(--text); }
.acc__head:hover { background: var(--surface-2); }
.acc__q { font-weight: 700; flex:1; }
.acc__chev { transition: transform .2s; color: var(--text-dim); }
.acc--open .acc__chev { transform: rotate(90deg); }
.acc__body { padding: 0 1.1rem 1.1rem; color: var(--text-soft); display:none; }
.acc--open .acc__body { display:block; animation: rise .25s both; }
.acc__body p + p { margin-top:.6rem }
.acc__body ul { margin: .5rem 0 .5rem 1.1rem; }
.acc__body li { margin: .2rem 0; }

/* Artikel-Lesefluss (Ratgeber) */
.md__h { margin: 1.1rem 0 .35rem; color: var(--text); font-size: 1.05rem; }
h3.md__h { font-size: 1.18rem; }
.md p { line-height: 1.65; }
.md p + p { margin-top: .7rem; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.article { max-width: 74ch; }
.article__meta { display:flex; gap:.5rem; flex-wrap:wrap; align-items:center; margin:.2rem 0 1rem; }
.article__lead { font-size: 1.08rem; color: var(--text-soft); line-height: 1.6; }
.article__foot { margin-top: 1.4rem; padding-top: .9rem; border-top: 1px solid var(--border); color: var(--text-dim); font-size: .82rem; }
.article-card { cursor: pointer; transition: border-color .15s, transform .08s; }
.article-card:hover { border-color: var(--brand); }
.article-card:active { transform: translateY(1px); }

/* Quer-Verweise auf geprüfte Artikel (dezent) */
.reflist { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; background: var(--surface-2); }
.reflist__head { display:flex; align-items:center; gap:.5rem; margin-bottom:.5rem; color: var(--text-soft); font-size:.92rem; }
.reflist__head .tag { margin-left:auto; }
.reflist__items { display:flex; flex-direction:column; }
.reflist__item { display:flex; align-items:center; gap:.6rem; padding:.5rem .2rem; color: var(--text);
  border-top: 1px solid var(--border-soft); text-decoration:none; font-weight:600; font-size:.9rem; }
.reflist__item:first-child { border-top:none; }
.reflist__item:hover { color: var(--brand-ink); text-decoration:none; }
.reflist__item .reflist__title { flex:1; }
.reflist__item .ic:last-child { color: var(--text-dim); }
.reflist__item:hover .ic:last-child { color: var(--brand-ink); }

/* Stepper */
.stepper { display:flex; align-items:center; gap:.4rem; flex-wrap:wrap; }
.stepper__dot { width: 9px; height: 9px; border-radius:50%; background: var(--surface-3); }
.stepper__dot--done { background: var(--brand); }
.stepper__dot--now { background: var(--brand); box-shadow: var(--ring); }

/* Tables */
table.tbl { width:100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align:left; padding: .55rem .6rem; border-bottom: 1px solid var(--border-soft); }
.tbl th { color: var(--text-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:hover td { background: var(--surface-2); }

/* Mobil: .tbl--cards rendert jede Zeile als gestapelte Karte (Spaltenlabel vor Wert). */
@media (max-width: 600px) {
  .tbl--cards { display: block; }
  .tbl--cards thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .tbl--cards tbody, .tbl--cards tfoot { display: block; }
  .tbl--cards tr { display: block; border: 1px solid var(--border); border-radius: 12px; padding: .25rem .65rem; margin-bottom: .55rem; background: var(--surface); }
  .tbl--cards tfoot tr { background: var(--surface-2); }
  .tbl--cards tr:hover td { background: transparent; }
  .tbl--cards td { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--border-soft); text-align: right; }
  .tbl--cards tr td:last-child { border-bottom: 0; }
  .tbl--cards td.num { text-align: right; }
  .tbl--cards td::before { content: attr(data-label); flex: 0 0 auto; text-align: left; color: var(--text-dim); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .tbl--cards td .input, .tbl--cards td .inputgroup { flex: 1 1 auto; min-width: 0; max-width: 60%; }
  .tbl--cards td > .btn { margin-left: auto; }
}

/* Chart */
.chart { width: 100%; }
.chart text { fill: var(--text-dim); font-size: 11px; font-family: var(--font); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid-line { stroke: var(--border-soft); stroke-width: 1; stroke-dasharray: 3 4; }
.legend { display:flex; gap: 1rem; flex-wrap: wrap; font-size:.82rem; color: var(--text-soft); }
.legend__item { display:flex; align-items:center; gap:.4rem; }
.legend__swatch { width: 12px; height: 12px; border-radius: 4px; }

.chart-tip {
  background: var(--surface-3); border:1px solid var(--border); border-radius: 10px;
  padding:.5rem .65rem; font-size:.8rem; box-shadow: var(--shadow); white-space: nowrap; z-index: 5;
}

/* Timeline / Fahrplan */
.timeline { position: relative; margin-left: .6rem; }
.tl-item { position: relative; padding: 0 0 1.2rem 1.9rem; border-left: 2px solid var(--border); }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-dot { position:absolute; left: -11px; top: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--border); display: grid; place-items: center; }
.tl-dot .ic { width: 12px; height: 12px; }
.tl-item--done > .tl-dot { background: var(--mint); border-color: var(--mint); color: #06121f; }
.tl-item--now > .tl-dot { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); box-shadow: var(--ring); }
.tl-item--done { border-left-color: var(--mint); }

/* Check-Item */
.chk { display:flex; gap:.7rem; align-items:flex-start; width:100%; text-align:left; padding:.55rem .2rem;
  background:none; border:none; cursor:pointer; color:var(--text); border-bottom:1px solid var(--border-soft); }
.chk:last-child { border-bottom: none; }
.chk__box { width:22px; height:22px; border-radius:7px; border:2px solid var(--border); flex:none; display:grid; place-items:center; margin-top:1px; }
.chk--done .chk__box { background: var(--mint); border-color: var(--mint); color:#06121f; }
.chk--done .chk__label { color: var(--text-dim); text-decoration: line-through; }
.chk__box .ic { width:14px; height:14px; opacity:0; }
.chk--done .chk__box .ic { opacity:1; }

/* Vergleichs-Tabelle (sticky erste Spalte) */
.cmp-wrap { overflow-x: auto; }
.cmp { border-collapse: collapse; width: 100%; min-width: 520px; }
.cmp th, .cmp td { padding: .6rem .7rem; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.cmp th.rowhead, .cmp td.rowhead { position: sticky; left: 0; background: var(--surface); font-weight: 600; color: var(--text-soft); z-index: 1; }
.cmp td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cmp .best { color: var(--mint); font-weight: 700; }
.cmp thead th { font-size: .9rem; }
.rank-badge { display:inline-grid; place-items:center; width:24px; height:24px; border-radius:50%; background: var(--surface-3); font-size:.78rem; font-weight:800; }
.rank-badge--1 { background: var(--grad-mint); color:#06121f; }

/* Toast */
.toast-wrap { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 80; display:flex; flex-direction:column; gap:.5rem; }
.toast { background: var(--surface-3); border:1px solid var(--border); border-radius: 12px; padding:.7rem 1rem; box-shadow: var(--shadow); animation: rise .25s both; max-width: 320px; font-size: .9rem; }

/* Utility grids */
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.split { display:grid; grid-template-columns: 1.05fr .95fr; gap: 1.2rem; align-items: start; }

/* Bottom nav (mobile) */
.botnav { display: none; }

/* ----------------------------------------------------------------- Responsive */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .split { grid-template-columns: 1fr; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .main { padding-bottom: 6rem; }
  .botnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: .35rem .35rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .botnav__item { display:flex; flex-direction:column; align-items:center; gap:2px; padding:.45rem 0;
    background:none; border:none; color: var(--text-dim); font-size:.68rem; font-weight:600; cursor:pointer; }
  .botnav__item .ic { width: 22px; height: 22px; }
  .botnav__item--active { color: var(--brand-ink); }
  /* Elemente, die auf Mobil weichen sollen (z. B. „Planer starten" oben rechts –
     konkurriert mit „Anmelden"; der Planer ist über die untere Leiste erreichbar). */
  .hide-mobile { display: none !important; }
}
@media (min-width: 921px) { .only-mobile { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto; }
}

/* print */
/* Lead-/Kontaktformular */
.lead-card { border-color: color-mix(in srgb, var(--brand) 40%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), var(--bg-soft)); }
.lead-consent { display:flex; gap:.6rem; align-items:flex-start; margin-top:1rem; font-size:.86rem; color:var(--text-soft); cursor:pointer; }
.lead-consent input { margin-top:3px; width:18px; height:18px; flex:none; accent-color: var(--brand); }
.lead-err { margin-top:.7rem; color:#06121f; background:var(--amber); border-radius:10px; padding:.5rem .8rem; font-size:.86rem; font-weight:600; }
textarea.input { resize: vertical; }

/* Meine Fälle */
.cases-list { display:flex; flex-direction:column; }
.case-row { display:flex; align-items:center; gap:.8rem; padding:.6rem 0; border-top:1px solid var(--border-soft); }
.case-row:first-child { border-top:none; }

/* Druck-Kopf nur beim Drucken sichtbar */
.print-only { display: none; }
.print-head { display: none; }
.printsheet { display: none; }

@media print {
  :root {
    color-scheme: light;
    --bg:#fff; --bg-soft:#fff; --surface:#fff; --surface-2:#f7f8fa; --surface-3:#eef0f3;
    --border:#d7deea; --border-soft:#e9edf3; --text:#111; --text-soft:#333; --text-dim:#666;
  }
  body { background:#fff; }
  .sidebar, .topbar, .botnav, .composer, .suggests, .appfoot, .no-print { display: none !important; }
  body::before { display:none; }
  .shell { display:block; }
  .main { padding: 0; max-width: none; }
  .card { break-inside: avoid; box-shadow:none; border-color:#ddd; }
  .split { display:block !important; }
  .print-only { display: block; }
  .print-head {
    display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
    border-bottom: 2px solid #222; padding: 0 0 .5rem; margin: 0 0 1rem; color:#111;
  }
  .print-head .print-date { margin-left: auto; color:#555; }
  /* Im Druck dunkle Flächen vermeiden für lesbares PDF */
  .view, .card { color: #111; }

  /* --- Gebrandetes Ergebnis-Dossier --- */
  @page { margin: 16mm 14mm; }
  body.printing .shell, body.printing .botnav, body.printing .toast-wrap { display: none !important; }
  body.printing .printsheet { display: block; color: #111; }
  .ps-head { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid var(--brand, #2563eb); padding-bottom: 12px; margin-bottom: 18px; }
  .ps-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 10px; flex: none; }
  .ps-logo--mark { background: var(--brand, #2563eb); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 26px; }
  .ps-name { font-weight: 800; font-size: 18px; color: #111; }
  .ps-product { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #666; }
  .ps-meta { margin-left: auto; text-align: right; }
  .ps-title { font-weight: 700; font-size: 16px; color: #111; }
  .ps-date { font-size: 12px; color: #666; }
  .ps-body .card { break-inside: avoid; border: 1px solid #e3e6ee; box-shadow: none; background: #fff; margin-bottom: 12px; }
  .ps-foot { margin-top: 20px; padding-top: 10px; border-top: 1px solid #ddd; font-size: 11px; color: #555; display: flex; justify-content: space-between; gap: 1rem; }
}
