/* besorga – Designsystem. Fundament-Datei: Module ergänzen eigenes CSS in public/css/<modul>.css.
   Idee: Wiener Haustor (Tannengrün), Schönbrunner Gelb als Akzent, Hausnummernschild-Motiv (Wiener Straßenschild-Blau).
   Schriften lokal (DSGVO): Hanken Grotesk (Text, UI), Newsreader (Überschriften, Kennzahlen). */

@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/static/fonts/hanken-grotesk-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/static/fonts/hanken-grotesk-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Newsreader'; font-style: normal; font-display: swap; font-weight: 200 800; src: url(/static/fonts/newsreader-latin-opsz-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Newsreader'; font-style: normal; font-display: swap; font-weight: 200 800; src: url(/static/fonts/newsreader-latin-ext-opsz-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Newsreader'; font-style: italic; font-display: swap; font-weight: 200 800; src: url(/static/fonts/newsreader-latin-opsz-italic.woff2) format('woff2'); unicode-range: U+0000-00FF, U+20AC; }

:root {
  /* Kernpalette */
  --tor: #1E4A3B;          /* Haustorgrün – Primärfarbe */
  --tor-dk: #14352A;
  --tor-hell: #E3EDE8;
  --gelb: #EDB83A;         /* Schönbrunner Gelb – Akzent, KI */
  --gelb-hell: #FBF1D3;
  --gelb-dk: #7A5800;
  --schild: #1D3B6E;       /* Wiener Straßenschild-Blau */
  --putz: #F3F4F1;         /* Hintergrund */
  --surface: #FFFFFF;
  --surface-2: #F8F9F6;
  --tinte: #17211D;        /* Text */
  --stein: #5B6761;        /* Sekundärtext */
  --line: #DCE1DB;
  --line-2: #C9D0C8;
  /* Status */
  --ok: #2B7A4B;   --ok-bg: #E2F1E7;
  --info: #285E8A; --info-bg: #E3EDF6;
  --warn: #9A6200; --warn-bg: #FBEFD6;
  --danger: #A8352A; --danger-bg: #F8E4E0;
  --neutral: #4E5853; --neutral-bg: #ECEEEA;
  /* Chart-Serien */
  --c1: #1E4A3B; --c2: #EDB83A; --c3: #285E8A; --c4: #A8352A; --c5: #8FA89A;
  /* Typo */
  --f-sans: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .9375rem; --fs-md: 1.0625rem; --fs-lg: 1.25rem; --fs-xl: 1.625rem; --fs-2xl: 2.125rem; --fs-3xl: 2.875rem;
  /* Raum */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(23, 33, 29, .06), 0 2px 8px -2px rgba(23, 33, 29, .06);
  --shadow-pop: 0 10px 30px -8px rgba(20, 53, 42, .28);
  --focus: 0 0 0 3px rgba(237, 184, 58, .55);
  --sidebar-w: 248px;
  color-scheme: light;
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--f-sans); font-size: var(--fs-base); line-height: 1.55; color: var(--tinte); background: var(--putz); font-feature-settings: 'tnum' 0, 'ss01'; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
svg.i { display: inline-block; flex: none; vertical-align: -.2em; }
a { color: var(--tor); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--tor-dk); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
h1, h2, h3, h4 { margin: 0 0 var(--s3); line-height: 1.2; font-weight: 600; }
h1 { font-family: var(--f-serif); font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -.01em; font-optical-sizing: auto; }
h2 { font-family: var(--f-serif); font-size: var(--fs-xl); font-weight: 500; letter-spacing: -.005em; }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
p { margin: 0 0 var(--s3); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--stein); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--f-serif); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

/* ---------- Layout-Helfer ---------- */
.stack > * + * { margin-top: var(--s4); }
.stack--lg > * + * { margin-top: var(--s6); }
.stack--sm > * + * { margin-top: var(--s2); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.row { display: flex; gap: var(--s4); align-items: center; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }
.grid { display: grid; gap: var(--s4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--main { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

/* ---------- Marke ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--tor); }
.logo__wort { font-family: var(--f-serif); font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; line-height: 1; padding-bottom: 2px; }
.logo--invers { color: #fff; --logo-tor: #fff; --logo-linie: rgba(30, 74, 59, .35); --logo-gelb: var(--gelb); }
.logo--invers .signet path:first-child { fill: #F3F4F1; }
.logo--invers .signet path:nth-child(2) { stroke: #C9D6CF; }
.logo--invers .signet path:last-child { stroke: #F3F4F1; }

/* Hausnummernschild: Wiener Straßenschild als Kennzeichen für Liegenschaften/Tops */
.schild { display: inline-flex; align-items: center; gap: 4px; background: var(--schild); color: #fff; font-weight: 650; font-size: var(--fs-sm); letter-spacing: .01em; line-height: 1; padding: 5px 8px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--schild), inset 0 0 0 2.5px rgba(255, 255, 255, .92); white-space: nowrap; font-variant-numeric: tabular-nums; }
.schild--sm { font-size: var(--fs-xs); padding: 4px 6px; }
.schild--xl { font-family: var(--f-serif); font-size: 3.2rem; padding: 14px 26px 18px; border-radius: 10px; box-shadow: inset 0 0 0 4px var(--schild), inset 0 0 0 7px rgba(255, 255, 255, .95); }

/* ---------- Buttons ---------- */
.btn { --b-bg: var(--surface); --b-fg: var(--tinte); --b-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 15px; border: 1px solid var(--b-bd); border-radius: 8px;
  background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 600; font-size: var(--fs-base); line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s; }
.btn:hover { --b-bg: var(--surface-2); color: var(--b-fg); border-color: var(--stein); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn--primary { --b-bg: var(--tor); --b-fg: #fff; --b-bd: var(--tor); }
.btn--primary:hover { --b-bg: var(--tor-dk); border-color: var(--tor-dk); }
.btn--accent { --b-bg: var(--gelb); --b-fg: var(--tinte); --b-bd: #D9A52C; }
.btn--accent:hover { --b-bg: #E2AA2A; border-color: #C8961F; }
.btn--ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--tor); }
.btn--ghost:hover { --b-bg: var(--tor-hell); border-color: transparent; }
.btn--danger { --b-bg: var(--surface); --b-fg: var(--danger); --b-bd: #E3B9B2; }
.btn--danger:hover { --b-bg: var(--danger-bg); border-color: var(--danger); }
.btn--sm { min-height: 30px; padding: 5px 10px; font-size: var(--fs-sm); border-radius: 7px; }
.btn--lg { min-height: 48px; padding: 12px 22px; font-size: var(--fs-md); border-radius: 10px; }
.btn--block { width: 100%; }
.btn--icon { min-width: 38px; padding: 8px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--b-fg) transparent var(--b-fg) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5) 0; }
.card__title { margin: 0; font-family: var(--f-sans); font-size: var(--fs-md); font-weight: 650; }
.card__head .spacer + * , .card__actions { margin-left: auto; }
.card__body { padding: var(--s4) var(--s5) var(--s5); }
.card__foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }
.card--flush .card__body { padding: 0; }
.card--flat { box-shadow: none; }
.card--tor { background: var(--tor); color: #E8F0EC; border-color: var(--tor); }
.card--tor .card__title, .card--tor h2, .card--tor h3 { color: #fff; }
.card--ki { border-color: #EAD49A; background: linear-gradient(180deg, var(--gelb-hell), var(--surface) 70%); }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.card:hover { border-color: var(--line-2); }

/* ---------- KPI-Kacheln ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s5); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi__label { display: flex; align-items: center; gap: 6px; color: var(--stein); font-size: var(--fs-sm); font-weight: 550; }
.kpi__value { font-family: var(--f-serif); font-size: 2.25rem; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; margin-top: 4px; }
.kpi__value small { font-family: var(--f-sans); font-size: var(--fs-md); color: var(--stein); font-weight: 500; letter-spacing: 0; margin-left: 2px; }
.kpi__meta { font-size: var(--fs-sm); color: var(--stein); }
.kpi__trend--up { color: var(--ok); font-weight: 600; }
.kpi__trend--down { color: var(--danger); font-weight: 600; }
.kpi--tor { background: var(--tor); border-color: var(--tor); color: #fff; }
.kpi--tor .kpi__label, .kpi--tor .kpi__meta { color: #BFD3C9; }
.kpi--gelb { background: var(--gelb-hell); border-color: #EAD49A; }
.kpi--warn .kpi__value { color: var(--danger); }

/* ---------- Badges, Chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 650; line-height: 1.6; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--ki { background: var(--gelb-hell); color: var(--gelb-dk); box-shadow: inset 0 0 0 1px #EAD49A; }
.badge--ki::before { width: 8px; height: 8px; border-radius: 0; background: currentColor; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.badge--plain::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: var(--fs-xs); font-weight: 600; color: var(--stein); background: var(--surface); white-space: nowrap; }
.chip--demo { border-color: #EAD49A; background: var(--gelb-hell); color: var(--gelb-dk); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th { text-align: left; font-size: var(--fs-sm); font-weight: 600; color: var(--stein); padding: 10px var(--s4); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 11px var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr.is-link { cursor: pointer; }
.table tbody tr.is-link:hover td, .table tbody tr:hover td { background: #FAFBF8; }
.table tr.is-alert td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table--compact td, .table--compact th { padding: 7px var(--s3); }
.table a.row-link { color: inherit; text-decoration: none; font-weight: 600; }
.table a.row-link:hover { color: var(--tor); text-decoration: underline; }
.table .sub { display: block; font-size: var(--fs-sm); color: var(--stein); font-weight: 400; }
.card .table th:first-child, .card .table td:first-child { padding-left: var(--s5); }
.card .table th:last-child, .card .table td:last-child { padding-right: var(--s5); }
.card--flush .table th { border-top: 0; }
.card--flush .table thead tr:first-child th:first-child { border-top-left-radius: var(--r); }
.card--flush .table thead tr:first-child th:last-child { border-top-right-radius: var(--r); }
/* Tabellen auf Mobil als Karten: <table class="table table--stack"> + data-label an td */
@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack tr { display: block; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .table--stack td { display: flex; justify-content: space-between; gap: var(--s3); padding: 3px 0 !important; border: 0; text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--stein); font-size: var(--fs-sm); text-align: left; }
  .table--stack td:first-child { display: block; text-align: left; font-weight: 600; }
  .table--stack td:first-child::before { display: none; }
}

/* ---------- Listen (Posteingang, Tickets, Aktivität) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list__item:last-child { border-bottom: 0; }
a.list__item:hover { background: #FAFBF8; }
.list__item.is-unread .list__title { font-weight: 700; }
.list__item.is-active { background: var(--tor-hell); }
.list__main { display: block; min-width: 0; flex: 1; }
.list__title { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__meta { display: block; font-size: var(--fs-sm); color: var(--stein); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__aside { flex: none; text-align: right; font-size: var(--fs-sm); color: var(--stein); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.icon-dot { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--tor-hell); color: var(--tor); }
.icon-dot--warn { background: var(--warn-bg); color: var(--warn); }
.icon-dot--danger { background: var(--danger-bg); color: var(--danger); }
.icon-dot--ki { background: var(--gelb-hell); color: var(--gelb-dk); }
.icon-dot--info { background: var(--info-bg); color: var(--info); }

/* Timeline (Ticket-Verlauf) */
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 var(--s4); }
.timeline li::before { content: ''; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--tor); }
.timeline li.is-ki::before { border-color: var(--gelb); background: var(--gelb); }
.timeline li.is-intern { opacity: .85; }
.timeline__meta { font-size: var(--fs-sm); color: var(--stein); }

/* Schlüssel-Wert-Liste */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s5); margin: 0; }
.dl dt { color: var(--stein); font-size: var(--fs-sm); padding-top: 1px; }
.dl dd { margin: 0; font-weight: 500; }
@media (max-width: 480px) { .dl { grid-template-columns: 1fr; gap: 0; } .dl dd { margin-bottom: var(--s2); } }

/* ---------- Formulare ---------- */
.form { display: grid; gap: var(--s4); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--tinte); }
.field__hint { font-size: var(--fs-sm); color: var(--stein); }
.field__error { font-size: var(--fs-sm); color: var(--danger); font-weight: 550; }
.input, input:not([type]), input[type=url], input[type=month], input[type=time], .select, .textarea, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--tinte); font: inherit; font-size: max(16px, var(--fs-base)); line-height: 1.4; transition: border-color .15s, box-shadow .15s; }
@media (min-width: 761px) { .input, input:not([type]), input[type=url], input[type=month], input[type=time], input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea { font-size: var(--fs-base); } }
textarea, .textarea { min-height: 110px; resize: vertical; }
select, .select { appearance: none; padding-right: 34px; 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='%235B6761' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tor); box-shadow: 0 0 0 3px rgba(30, 74, 59, .15); }
.is-invalid { border-color: var(--danger) !important; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-base); cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--tor); flex: none; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--stein); pointer-events: none; }
.search input { padding-left: 36px; }
.filterbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.filterbar > * { width: auto; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; color: var(--stein); font-weight: 600; text-decoration: none; white-space: nowrap; border-radius: 8px 8px 0 0; }
.tab:hover { color: var(--tinte); background: rgba(30, 74, 59, .05); }
.tab.is-active, .tab[aria-current=page], .tab--active { color: var(--tor); }
.tab.is-active::after, .tab[aria-current=page]::after, .tab--active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--gelb); }
.tab .count { font-size: var(--fs-xs); background: var(--neutral-bg); color: var(--stein); padding: 0 7px; border-radius: 99px; }
/* Segment-Schalter */
.segmented { display: inline-flex; background: var(--neutral-bg); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented a, .segmented button { border: 0; background: transparent; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--stein); padding: 5px 12px; border-radius: 7px; text-decoration: none; cursor: pointer; }
.segmented .is-active { background: var(--surface); color: var(--tinte); box-shadow: var(--shadow); }

/* ---------- Leerzustand, Hinweise ---------- */
.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--stein); }
.empty__icon { width: 52px; height: 52px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center; background: var(--tor-hell); color: var(--tor); }
.empty__title { font-family: var(--f-serif); font-size: var(--fs-lg); color: var(--tinte); margin-bottom: 4px; }
.empty__text { max-width: 44ch; margin: 0 auto var(--s4); }
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--info-bg); color: #1F4566; font-size: var(--fs-base); }
.notice svg { margin-top: 2px; }
.notice--warn { background: var(--warn-bg); color: #6A4400; }
.notice--danger { background: var(--danger-bg); color: #7A2219; }
.notice--ok { background: var(--ok-bg); color: #1E5A37; }
.notice--ki { background: var(--gelb-hell); color: #5C4300; box-shadow: inset 0 0 0 1px #EAD49A; }
/* KI-Entwurf: Text, der vor dem Senden geprüft wird */
.draft { position: relative; border: 1px dashed #D9B860; background: #FFFCF2; border-radius: var(--r); padding: var(--s4) var(--s5); white-space: pre-wrap; font-size: var(--fs-base); line-height: 1.6; }
.draft__label { position: absolute; top: -10px; left: 14px; background: #FFFCF2; padding: 0 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--gelb-dk); }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 10px; background: var(--tinte); color: #fff; box-shadow: var(--shadow-pop); font-weight: 550; max-width: calc(100vw - 32px); animation: toast-in .25s ease-out; }
.toast--ok svg { color: #8BD3A6; }
.toast--danger { background: var(--danger); }
.toast--warn svg { color: var(--gelb); }
.toast.is-hiding { opacity: 0; transform: translate(-50%, 8px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
body.portal .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---------- Avatar, Meter, Charts ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--tor-hell); color: var(--tor); font-weight: 700; font-size: var(--fs-sm); flex: none; list-style: none; cursor: default; }
.avatar--sm { width: 26px; height: 26px; font-size: var(--fs-xs); }
.meter { height: 8px; background: var(--neutral-bg); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.meter--warn span { background: var(--gelb); }
.meter--danger span { background: var(--danger); }
.meter--tor span { background: var(--tor); }
.chart { width: 100%; display: block; overflow: visible; }
.chart-x { display: flex; margin-top: 6px; font-size: 11px; color: var(--stein); }
.chart-x span { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; }
.chart-axis { stroke: var(--line-2); stroke-width: 1; }
.chart-label { font: 500 11px var(--f-sans); fill: var(--stein); }
.chart-empty { padding: var(--s6); text-align: center; color: var(--stein); font-size: var(--fs-sm); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: var(--fs-sm); color: var(--stein); margin-top: var(--s2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend--list { list-style: none; padding: 0; margin: 0; flex-direction: column; gap: 6px; }
.chart-legend--list b { color: var(--tinte); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.donut { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut-center { font: 500 26px var(--f-serif); fill: var(--tinte); }
.donut-sub { font: 500 11px var(--f-sans); fill: var(--stein); }
.spark { display: inline-block; vertical-align: middle; }

/* ---------- Seitenkopf ---------- */
.page-head { margin-bottom: var(--s5); }
.page-head__back { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--stein); text-decoration: none; margin-bottom: var(--s2); }
.page-head__back:hover { color: var(--tor); }
.page-head__row { display: flex; gap: var(--s4); align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-head__title { margin: 0; }
.page-head__sub { margin: 4px 0 0; color: var(--stein); max-width: 70ch; }
.page-head__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.section-title { font-family: var(--f-sans); font-size: var(--fs-md); font-weight: 650; margin: var(--s6) 0 var(--s3); }

/* ---------- App-Shell (Verwalter) ---------- */
body.app { background: var(--putz); }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; background: var(--tor); color: #D5E2DB; padding: var(--s4) var(--s3); overflow-y: auto; }
.sidebar__brand { padding: 6px 10px var(--s5); }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__group { margin: var(--s4) 10px 6px; font-size: var(--fs-xs); font-weight: 600; color: #93AFA2; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #D5E2DB; text-decoration: none; font-weight: 550; position: relative; border: 0; background: none; font: inherit; width: 100%; cursor: pointer; text-align: left; }
.nav-item svg { color: #A9C2B6; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.is-active { background: rgba(255, 255, 255, .11); color: #fff; }
.nav-item.is-active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gelb); }
.nav-item.is-active svg { color: var(--gelb); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--gelb); color: var(--tinte); font-size: var(--fs-xs); font-weight: 700; text-align: center; line-height: 20px; }
.sidebar__foot { border-top: 1px solid rgba(255, 255, 255, .12); padding-top: var(--s3); margin-top: var(--s4); }
.sidebar__mandant { font-size: var(--fs-xs); color: #93AFA2; padding: 0 10px 6px; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: 10px var(--s6); background: rgba(243, 244, 241, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar__menu { display: none; }
.topbar__title { min-width: 0; flex: 1; }
.topbar__h { font-weight: 650; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs { display: flex; gap: 6px; font-size: var(--fs-sm); color: var(--stein); flex-wrap: wrap; }
.crumbs a { color: var(--stein); text-decoration: none; }
.crumbs a:hover { color: var(--tor); }
.topbar__right { display: flex; align-items: center; gap: var(--s3); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip__txt { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip__txt b { font-size: var(--fs-sm); }
.user-chip__txt small { font-size: var(--fs-xs); color: var(--stein); }
.app-content { padding: var(--s6); width: 100%; max-width: 1440px; }
.app-content--narrow { max-width: 920px; }
.sidebar-scrim { display: none; }
@media (max-width: 960px) {
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-pop); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(20, 30, 25, .4); }
  .topbar { padding: 8px var(--s4); }
  .topbar__menu { display: inline-flex; }
  .app-content { padding: var(--s4); }
  .user-chip__txt { display: none; }
}
@media (max-width: 520px) { .chip--demo { display: none; } }

/* ---------- Portal (Bewohner) ---------- */
body.portal { background: var(--putz); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.portal-head { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.portal-head__in { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: var(--s4); padding: 10px var(--s4); padding-top: max(10px, env(safe-area-inset-top)); }
.portal-head__right { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.portal-main { max-width: 720px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); }
.portal-title { font-size: var(--fs-xl); margin-bottom: var(--s4); }
.portal-nav { display: flex; }
.portal-nav--top { display: none; }
.portal-nav--bottom { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
.ptab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; color: var(--stein); text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 10px; position: relative; min-width: 0; }
.ptab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ptab.is-active { color: var(--tor); }
.ptab.is-active svg { color: var(--tor); }
.portal-nav--bottom .ptab.is-active::before { content: ''; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gelb); }
.ptab .nav-badge { position: absolute; top: 0; right: 18%; margin: 0; min-width: 18px; line-height: 17px; padding: 0 5px; font-size: 10px; }
@media (min-width: 761px) {
  body.portal { padding-bottom: 0; }
  .portal-nav--bottom { display: none; }
  .portal-nav--top { display: flex; gap: 2px; margin-left: var(--s4); }
  .portal-nav--top .ptab { flex-direction: row; gap: 7px; font-size: var(--fs-sm); padding: 8px 12px; }
  .portal-nav--top .ptab.is-active { background: var(--tor-hell); }
  .portal-nav--top .ptab .nav-badge { position: static; }
  .portal-main { padding-top: var(--s6); }
}
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__pop { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: var(--s3); z-index: 40; }
.menu__who { display: flex; flex-direction: column; padding: 4px 4px var(--s3); }
.menu__who small { color: var(--stein); }

/* ---------- Öffentliche Seiten ---------- */
body.public { background: var(--putz); }
.site-head { position: sticky; top: 0; z-index: 20; background: rgba(243, 244, 241, .9); backdrop-filter: blur(8px); border-bottom: 1px solid transparent; }
.site-head__in, .site-foot__in, .wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--s5); }
.site-head__in { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 68px; }
.site-nav { display: flex; align-items: center; gap: var(--s4); }
.site-nav a:not(.btn) { color: var(--tinte); text-decoration: none; font-weight: 550; }
.site-nav a:not(.btn):hover { color: var(--tor); }
@media (max-width: 640px) { .site-nav a:not(.btn) { display: none; } }
.site-main { min-height: 60vh; }
.site-foot { border-top: 1px solid var(--line); margin-top: var(--s8); padding: var(--s6) 0 var(--s7); background: var(--surface-2); }
.site-foot__in { display: flex; justify-content: space-between; gap: var(--s5); flex-wrap: wrap; }
.site-foot__in p { margin-top: var(--s2); max-width: 40ch; }
.site-foot__links { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: flex-start; }
.site-foot__links a { color: var(--stein); text-decoration: none; font-size: var(--fs-sm); }
.site-foot__links a:hover { color: var(--tor); }
.prose { max-width: 68ch; font-size: var(--fs-md); line-height: 1.65; }
.prose h2 { margin-top: var(--s6); }
.prose h3 { margin-top: var(--s5); }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth__panel { display: flex; flex-direction: column; justify-content: center; padding: var(--s7) clamp(24px, 6vw, 88px); }
.auth__panel > * { width: 100%; max-width: 420px; }
.auth__art { position: relative; overflow: hidden; background: var(--tor); color: #E8F0EC; padding: var(--s7) clamp(24px, 5vw, 72px); display: flex; flex-direction: column; justify-content: flex-end; }
.auth__art::before { content: ''; position: absolute; right: -8%; top: -6%; width: 78%; aspect-ratio: 3 / 4; border-radius: 50% 50% 0 0 / 38% 38% 0 0; border: 2px solid rgba(237, 184, 58, .55); box-shadow: 0 0 0 26px rgba(255, 255, 255, .035), 0 0 0 54px rgba(255, 255, 255, .025); }
.auth__claim { position: relative; font-family: var(--f-serif); font-size: clamp(2rem, 3.6vw, 3.1rem); line-height: 1.08; letter-spacing: -.02em; color: #fff; font-weight: 450; margin: 0 0 var(--s4); max-width: 13ch; }
.auth__lede { position: relative; max-width: 40ch; color: #BFD3C9; font-size: var(--fs-md); }
.auth__h { font-size: var(--fs-xl); margin: var(--s6) 0 var(--s2); }
.demo-buttons { display: grid; gap: var(--s2); }
.demo-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); font: inherit; text-align: left; cursor: pointer; color: var(--tinte); transition: border-color .15s, background .15s; }
.demo-btn:hover { border-color: var(--tor); background: #FAFCFA; }
.demo-btn b { display: block; }
.demo-btn small { display: block; color: var(--stein); }
.demo-btn .chev { margin-left: auto; color: var(--stein); }
.divider { display: flex; align-items: center; gap: var(--s3); color: var(--stein); font-size: var(--fs-sm); margin: var(--s5) 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__art { order: -1; min-height: 0; padding: var(--s5) var(--s5) var(--s5); }
  .auth__art::before { width: 46%; right: -10%; top: -30%; }
  .auth__claim { font-size: 1.75rem; margin-bottom: var(--s2); }
  .auth__lede { display: none; }
  .auth__panel { padding: var(--s5); justify-content: flex-start; }
  .auth__h { margin-top: var(--s3); }
}

/* Fehlerseite */
.error-page { max-width: 560px; margin: var(--s8) auto; padding: 0 var(--s5); text-align: center; }
.error-page .schild { margin-bottom: var(--s5); }
.error-page .cluster { justify-content: center; margin-top: var(--s5); }

/* Platzhalter */
.placeholder { border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); padding: var(--s6); background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media print { .sidebar, .topbar, .portal-nav, .portal-head, .site-head, .site-foot, .toast { display: none !important; } body { background: #fff; } .app-content { padding: 0; } }

/* Integration: Grid-Kinder dürfen schrumpfen (sonst sprengen nowrap-Inhalte am Handy die Breite) */
.grid > * { min-width: 0; }
.list__main { min-width: 0; }
