:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --text: #1D1D1F;
  --muted: #6E6E73;
  --line: #E5E5EA;
  --line-soft: #F0F0F2;
  --fill: #E8E8ED;
  --accent: #0071E3;
  --accent-text: #0066CC;
  --accent-soft: #E8F1FC;
  --danger: #D70015;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { font-size: 15px; line-height: 1.4; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: #004C99; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid rgba(0,113,227,.45); outline-offset: 2px; border-radius: 8px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 28px 16px; background: rgba(255,255,255,.72); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: 19px; font-weight: 700; letter-spacing: -.3px; color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 12px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text); font-size: 15px; }
.nav a:hover { background: #EFEFF3; }
.nav a.active { background: var(--fill); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 13px; color: var(--muted); }
.nav .badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; background: var(--muted); }
.sidebar-foot { margin-top: auto; padding: 0 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent-text); font-size: 13px; text-align: left; }

.main { flex: 1; min-width: 0; padding: 40px clamp(20px, 4vw, 56px) 64px; display: flex; flex-direction: column; gap: 28px; max-width: 1280px; }
.tabbar { display: none; }

/* ---------- Typo & Bausteine ---------- */
.eyebrow { font-size: 15px; color: var(--muted); }
h1.title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; }
h2.section { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.row-between { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: 980px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #0077ED; color: #fff; }
.btn.secondary { background: var(--card); color: var(--accent-text); box-shadow: var(--shadow); }
.btn.secondary:hover { background: #FAFAFC; }
.btn.plain { background: #F5F5F7; color: var(--text); }
.btn.big { height: 50px; border-radius: 14px; font-size: 17px; font-weight: 600; width: 100%; }
.btn.danger { background: transparent; color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: #F5F5F7; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:hover { background: var(--fill); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 980px; background: var(--line-soft); color: var(--text); font-size: 13px; font-weight: 500; border: 0; }
button.chip.toggle { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
button.chip.toggle.on { background: var(--accent); color: #fff; box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* Suche */
.searchbar { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 20px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.searchbar input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; }
.searchbar input::-webkit-search-cancel-button { display: none; }
.kbd { padding: 3px 8px; border-radius: 6px; background: #F5F5F7; font-size: 12px; color: var(--muted); }

/* Hinweis-Karte */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 22px 26px; }
.banner .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner .txt { flex: 1 1 260px; display: flex; flex-direction: column; gap: 3px; }
.banner h2 { margin: 0; font-size: 19px; font-weight: 600; }

/* Bereiche */
.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.area { display: flex; flex-direction: column; gap: 18px; padding: 20px; color: var(--text); transition: transform .15s ease; }
.area:hover { color: var(--text); transform: translateY(-2px); }
.area .swatch { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--line-soft); }
.area .swatch .dot { width: 14px; height: 14px; border-radius: 7px; }
.area .txt { display: flex; flex-direction: column; gap: 2px; }
.area .name { font-size: 17px; font-weight: 600; }
.area .num { font-size: 14px; color: var(--muted); }

/* Liste */
.list { overflow: hidden; }
.item { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); color: var(--text); }
.item:last-child { border-bottom: 0; }
.item:hover { background: #FAFAFC; color: var(--text); }
.item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .t { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .hit { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .hit mark { background: #FFF2B3; color: inherit; border-radius: 3px; padding: 0 1px; }
.item .date { width: 92px; text-align: right; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.item .tag1 { flex-shrink: 0; }
.thumb { width: 38px; height: 50px; border-radius: 6px; background: #F5F5F7; border: 1px solid var(--line); flex-shrink: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.more { display: flex; justify-content: center; padding: 8px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Dokument */
.docbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.docbar .back { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; min-height: 40px; }
.docbar .spacer { flex: 1; }
.docbar .actions { display: flex; gap: 8px; }
.docgrid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.preview { flex: 999 1 520px; min-width: 0; border-radius: 20px; background: var(--fill); padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview iframe { width: 100%; height: min(80vh, 1100px); border: 0; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.preview img { max-width: 100%; max-height: 70vh; border-radius: 6px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.preview .placeholder { padding: 80px 20px; color: var(--muted); }
.details { flex: 1 1 340px; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.details .head { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.details .kicker { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.details h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.4px; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 20px; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; overflow-wrap: anywhere; }
.box { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.box .label { font-weight: 600; }
.note { padding: 10px 12px; border-radius: 12px; background: #FBFBFD; border: 1px solid var(--line-soft); white-space: pre-wrap; }
.note small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #FBFBFD; font-size: 16px;
}
textarea.input { resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(0,113,227,.15); }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.formgrid .full { grid-column: 1 / -1; }
.tagpick { display: flex; flex-direction: column; gap: 8px; }
.tagpick .chips { max-height: 160px; overflow-y: auto; }

/* Posteingang */
.inbox { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.inbox .preview { flex: 1 1 360px; }
.inbox .preview img { max-height: 60vh; }
.inbox .form { flex: 1 1 380px; max-width: 520px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress div { height: 4px; background: var(--accent); width: 0; transition: width .2s ease; }
.suggest { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent); }
.btnrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Upload */
.drop { padding: 48px 24px; border: 2px dashed #C7C7CC; border-radius: 20px; background: var(--card); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.upl { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
.upl:last-child { border-bottom: 0; }
.ok { color: #248A3D; } .err { color: var(--danger); }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: 100%; max-width: 380px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.login .brand { padding: 0; justify-content: center; font-size: 24px; margin-bottom: 4px; }
.login .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); background: rgba(29,29,31,.92); color: #fff; padding: 10px 18px; border-radius: 980px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: flex; justify-content: center; padding: 40px; }

/* ---------- Handy ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: calc(20px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); gap: 20px; }
  h1.title { font-size: 32px; }
  h2.section { font-size: 20px; }
  .areas { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .area { padding: 14px; gap: 12px; flex-direction: row; align-items: center; }
  .area .swatch { width: 30px; height: 30px; border-radius: 9px; }
  .area .swatch .dot { width: 11px; height: 11px; }
  .area .name { font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .area .txt { display: flex; flex-direction: row; flex: 1; min-width: 0; justify-content: space-between; align-items: baseline; gap: 6px; }
  .area .num { font-size: 13px; }
  .searchbar { height: 44px; padding: 0 12px; border-radius: 12px; background: var(--fill); box-shadow: none; }
  .kbd, .hide-m { display: none !important; }
  .item { padding: 11px 14px; gap: 12px; }
  .item .date { display: none; }
  .item .tag1 { display: none; }
  .thumb { width: 32px; height: 42px; }
  .banner { padding: 16px; gap: 14px; }
  .banner .ico { width: 44px; height: 44px; border-radius: 12px; }
  .banner h2 { font-size: 17px; }
  .banner .btn { display: none; }
  .details { max-width: none; }
  .preview iframe { height: 60vh; }
  .inbox .form { max-width: none; }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  #toast { bottom: calc(84px + var(--safe-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 8px calc(6px + var(--safe-bottom)); background: rgba(255,255,255,.92); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center; color: var(--muted); font-size: 11px; font-weight: 500; position: relative; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: #FF3B30; color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
}

.hide-d { display: none; }
.docbar .back { font-size: 15px; color: var(--accent-text); }
@media (max-width: 860px) { .hide-d { display: inline; } }
.stack.tight { gap: 4px; }
.stack.gap8 { gap: 8px; }
.login-sub { margin: 0; text-align: center; }
