:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --sunk: #eceff0;
  --ink: #17252a;
  --muted: #5b686c;
  --faint: #8b979a;
  --line: #dfe4e0;
  --biz: #1f6f5c;
  --biz-soft: #e3f0eb;
  --priv: #6a4c93;
  --priv-soft: #eee8f6;
  --today: #b57900;
  --today-soft: #fbf1d9;
  --late: #b3261e;
  --late-soft: #f9e3e1;
  --focus: #2563c9;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1517;
    --surface: #152024;
    --sunk: #1b282d;
    --ink: #e4ebe9;
    --muted: #9aa8ab;
    --faint: #6f7d80;
    --line: #253338;
    --biz: #57b99d;
    --biz-soft: #17322b;
    --priv: #b195dc;
    --priv-soft: #2a2238;
    --today: #e3a72b;
    --today-soft: #33280f;
    --late: #ef6b5f;
    --late-soft: #3a1d1b;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Gerüst ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.nav {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; padding: 0 10px 18px; display: flex; gap: 10px; align-items: center; }
.brand svg { width: 26px; height: 26px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s);
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: var(--sunk); color: var(--ink); }
.nav a.on { background: var(--biz-soft); color: var(--biz); }
.nav .badge { margin-left: auto; }
.nav .spacer { flex: 1; }
.nav .capture-btn { margin: 6px 0 10px; justify-content: center; }

.main { margin-left: var(--nav-w); padding: 28px 40px 80px; }
.page { max-width: 920px; margin: 0 auto; }
.page.wide { max-width: 1200px; }

.tabbar { display: none; }

@media (max-width: 899px) {
  .nav { display: none; }
  .main { margin-left: 0; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; position: relative;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--biz); }
  .tabbar .cap {
    width: 56px; height: 56px; margin: -22px auto 0; border-radius: 50%;
    background: var(--biz); color: #fff; display: grid; place-items: center;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--biz) 40%, transparent);
  }
  .tabbar .cap svg { width: 26px; height: 26px; }
  .tabbar .badge { position: absolute; top: 0; right: calc(50% - 22px); }
}

/* ---------- Kopfzeilen ---------- */
.head { display: flex; align-items: flex-end; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.head h1 { font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; font-weight: 650; }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
h2.sec {
  font-size: 13px; font-weight: 600; color: var(--muted); margin: 26px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
h2.sec .count { color: var(--faint); font-weight: 500; }
h2.sec.late { color: var(--late); }
h2.sec.today { color: var(--today); }

/* ---------- Heute: Datum + Fristleiste ---------- */
.dayhead { margin: 6px 0 22px; }
.dayhead .wd { font-size: 15px; color: var(--muted); font-weight: 500; }
.dayhead .date { font-size: clamp(34px, 7vw, 52px); line-height: 1; letter-spacing: -0.035em; font-weight: 600; margin-top: 2px; }
.dayhead .line { margin-top: 10px; color: var(--muted); }
.dayhead .line b { color: var(--ink); font-weight: 600; }

.strip {
  display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
}
.strip .d {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 8px; border-radius: var(--radius-s);
  border: 0; background: none; cursor: pointer; min-width: 0;
}
.strip .d:hover { background: var(--sunk); }
.strip .d.sel { background: var(--sunk); }
.strip .d .wd { font-size: 10.5px; color: var(--faint); text-transform: none; }
.strip .d .n { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.strip .d.t .n { color: #fff; background: var(--biz); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.strip .d.we .n { color: var(--muted); }
.strip .dots { display: flex; gap: 2px; height: 6px; }
.strip .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.dot-task { background: var(--ink); }
.dot-inv { background: var(--priv); }
.dot-ev { background: var(--biz); }
.dot-late { background: var(--late); }
.strip-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 8px 4px 0; flex-wrap: wrap; }
.strip-legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: 1px; }
@media (max-width: 600px) {
  .strip { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .strip .d:nth-child(n+8) { display: none; }
}

/* ---------- Listen ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.list > .item + .item { border-top: 1px solid var(--line); }
.item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; position: relative;
  text-decoration: none; color: inherit; background: none; border: 0; width: 100%; text-align: left;
}
a.item:hover, button.item:hover { background: color-mix(in srgb, var(--sunk) 60%, transparent); }
.item .title { font-weight: 550; overflow-wrap: anywhere; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--muted); white-space: nowrap; text-align: right; }
.item.unread .title { font-weight: 700; }
.item.done .title { text-decoration: line-through; color: var(--faint); }
.item.area-business::before, .item.area-private::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
}
.item.area-business::before { background: var(--biz); }
.item.area-private::before { background: var(--priv); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-weight: 600; }

.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--faint); background: none; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.check:hover { border-color: var(--biz); }
.check.on { background: var(--biz); border-color: var(--biz); color: #fff; }
.check svg { width: 13px; height: 13px; }

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 600; font-size: 13px; background: var(--biz-soft); color: var(--biz);
}
.avatar.private { background: var(--priv-soft); color: var(--priv); }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }

/* ---------- Kennzeichen ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 550; line-height: 1;
  padding: 4px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap;
}
.chip.biz { background: var(--biz-soft); color: var(--biz); }
.chip.priv { background: var(--priv-soft); color: var(--priv); }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.today { background: var(--today-soft); color: var(--today); }
.chip.high { background: var(--late-soft); color: var(--late); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--late); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}

/* ---------- Schaltflächen & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 550; text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: var(--faint); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--biz); border-color: var(--biz); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--late); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.iconbtn { border: 0; background: none; padding: 6px; border-radius: var(--radius-s); cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--sunk); color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }

label.f { display: block; }
label.f > span { display: block; font-size: 13px; font-weight: 550; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface); min-height: 40px;
}
textarea.input { resize: vertical; min-height: 120px; line-height: 1.5; }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.seg { display: inline-flex; background: var(--sunk); border-radius: var(--radius-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 5px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.panel + .panel { margin-top: 14px; }
.callout { border-radius: var(--radius-m); padding: 14px 16px; background: var(--today-soft); border: 1px solid color-mix(in srgb, var(--today) 30%, transparent); }
.callout.err { background: var(--late-soft); border-color: color-mix(in srgb, var(--late) 30%, transparent); }
.callout.ok { background: var(--biz-soft); border-color: color-mix(in srgb, var(--biz) 30%, transparent); }
.callout b { display: block; margin-bottom: 2px; }
.steps { margin: 8px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }
code.k { background: var(--sunk); padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }

/* ---------- Mail-Detail ---------- */
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 1099px) { .split { grid-template-columns: 1fr; } .split.has-detail > .split-list { display: none; } }
@media (min-width: 1100px) { .split-detail { position: sticky; top: 20px; } }
.mailhead h2 { font-size: 21px; letter-spacing: -0.01em; margin: 0 0 8px; line-height: 1.25; }
.summary { padding: 12px 14px; border-radius: var(--radius-m); background: var(--biz-soft); color: var(--ink); }
.summary.private { background: var(--priv-soft); }
.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; }
iframe.mailhtml { width: 100%; border: 0; min-height: 300px; background: #fff; border-radius: var(--radius-s); }
.att { display: flex; gap: 8px; flex-wrap: wrap; }
.att a, .att span { font-size: 13px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { flex: 1; min-width: 180px; }

/* ---------- Erfassen ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius-l); padding: 34px 16px; text-align: center;
  background: var(--surface); cursor: pointer; display: block;
}
.dropzone:hover, .dropzone.over { border-color: var(--biz); }
.dropzone svg { width: 40px; height: 40px; color: var(--biz); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs .t { position: relative; width: 84px; height: 110px; border-radius: var(--radius-s); overflow: hidden; background: var(--sunk); display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; }

/* ---------- Dialog ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 22, 0.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: var(--radius-l); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog h3 { margin: 0 0 14px; font-size: 18px; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 600px) {
  .overlay { place-items: end stretch; padding: 0; }
  .dialog { border-radius: var(--radius-l) var(--radius-l) 0 0; width: 100%; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: var(--radius-m); font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.error { background: var(--late); color: #fff; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: min(400px, 100%); }
.auth h1 { font-size: 30px; letter-spacing: -0.03em; margin: 14px 0 4px; }

.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline .item { align-items: center; }
.tl-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; color: var(--muted); }
.tl-icon svg { width: 15px; height: 15px; }
.total { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .cards3 { grid-template-columns: 1fr; } }
