:root {
  --bg: #f4efe6; --surface: #fffdf9; --ink: #13202b; --muted: #5d6b76; --line: #e2d9c8;
  --navy: #0f2a3d; --sand: #e9dcc3; --accent: #1f6f8b; --signal: #d9662a; --ok: #2f7d4f; --warn: #b7791f;
  --shadow: 0 1px 2px rgba(15,42,61,.06), 0 4px 16px rgba(15,42,61,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1a25; --surface: #12263a; --ink: #e8eef2; --muted: #9aabb8; --line: #213a50;
    --accent: #5fb3d0; --signal: #f08a3c; --ok: #5cbf86; --warn: #e3b04b; --shadow: none; color-scheme: dark;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.6rem; margin: .2rem 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
button, input { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: .6rem 1rem; }
.primary { background: var(--navy); color: var(--sand); font-weight: 600; }
.ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
input { width: 100%; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .9rem; color: var(--muted); margin: .7rem 0; }
label input { margin-top: .25rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.err { color: var(--signal); min-height: 1.2em; margin: .3rem 0; }

.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand img { width: 30px; height: 30px; }
.brand.big { font-size: 1.5rem; }
.brand.big img { width: 42px; height: 42px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .primary { width: 100%; margin-top: .4rem; }
.steps { padding-left: 1.2rem; }
.qr { display: block; margin: .6rem 0; width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }
code { word-break: break-all; font-size: .85rem; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: .6rem 16px; background: var(--navy); color: var(--sand); }
.top .ghost { border-color: rgba(233,220,195,.35); padding: .4rem .8rem; }
#tabs { display: flex; gap: .2rem; flex: 1; }
#tabs button { background: transparent; color: var(--sand); opacity: .75; padding: .45rem .8rem; }
#tabs button.on { opacity: 1; background: rgba(233,220,195,.14); }
.ic { margin-right: .35rem; }
.preview { background: var(--sand); color: var(--navy); font-size: .85rem; text-align: center; padding: .35rem 16px; }
main { max-width: 980px; margin: 0 auto; padding: 1.2rem 16px 6rem; }
.lead { font-size: 1.08rem; margin: 0 0 1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin-bottom: 1.4rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.kpi b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .82rem; }
.group h2 { text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; color: var(--muted); margin: 1.2rem 0 .5rem; }
.item { display: grid; grid-template-columns: 6px 1fr auto; gap: .9rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem .75rem 0; margin-bottom: .5rem; overflow: hidden; }
.item .bar { align-self: stretch; border-radius: 0 4px 4px 0; background: var(--line); }
.item.hoch .bar { background: var(--signal); } .item.mittel .bar { background: var(--warn); } .item.ok .bar { background: var(--ok); }
.item .t { font-weight: 600; } .item .d { color: var(--muted); font-size: .9rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; background: var(--bg); color: var(--accent); border: 1px solid var(--line); margin-right: .4rem; }
.item button { background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: .4rem .7rem; font-size: .85rem; white-space: nowrap; }

.mail-layout { display: grid; grid-template-columns: minmax(0, 340px) 1fr; gap: 1rem; align-items: start; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; margin-bottom: .45rem; cursor: pointer; }
.mail-list li.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mail-list .row { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; color: var(--muted); }
.mail-list .s { font-weight: 600; margin: .15rem 0; }
.status { font-size: .75rem; font-weight: 600; }
.status.Entwurf { color: var(--accent); } .status.Abgelegt { color: var(--ok); }
.draft { white-space: pre-wrap; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: .8rem; font-size: .92rem; }
dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; margin: .6rem 0 1rem; font-size: .9rem; }
dt { color: var(--muted); }

.chat { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1rem; }
.msg { max-width: 92%; padding: .75rem .95rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: var(--navy); color: var(--sand); border-color: var(--navy); }
.chip { display: block; margin-top: .5rem; background: var(--bg); color: var(--accent); border: 1px solid var(--line); text-align: left; }
.step { color: var(--muted); font-size: .88rem; }
.step::before { content: "✓ "; color: var(--ok); }
.step.run::before { content: "… "; color: var(--accent); }
.ask { position: sticky; bottom: 1rem; display: flex; gap: .5rem; background: var(--bg); padding: .4rem 0; }
.tbl { width: 100%; border-collapse: collapse; margin: .7rem 0; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { white-space: nowrap; text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.tbl td:nth-child(n+4), .tbl th:nth-child(n+4) { text-align: right; }
.tbl tfoot td { font-weight: 700; border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.notes { font-size: .85rem; color: var(--muted); padding-left: 1.1rem; }

.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .7rem; }
.source { display: flex; flex-direction: column; gap: .3rem; }
.source .st { font-size: .78rem; font-weight: 600; color: var(--warn); }
.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
.plain li { padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.plain small { color: var(--muted); }

@media (max-width: 760px) {
  .top { gap: .5rem; }
  .top .brand span { display: none; }
  #tabs { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; background: var(--navy); padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); }
  #tabs button { display: flex; flex-direction: column; align-items: center; font-size: .7rem; padding: .3rem .2rem; }
  .ic { margin: 0; font-size: 1.1rem; }
  .top .ghost { margin-left: auto; }
  .mail-layout { grid-template-columns: 1fr; }
  .item { grid-template-columns: 6px 1fr; }
  .item button { grid-column: 2; justify-self: start; }
  .ask { bottom: 4.4rem; }
}
