:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111827; --surface-2: #1f2937; --border: #263244;
    --text: #e5e7eb; --muted: #94a3b8; --primary: #2dd4bf; --primary-ink: #042f2e; --primary-soft: #134e4a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .75rem; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 1.2rem .8rem; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: .25rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; padding: 0 .6rem 1rem; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 10px; color: var(--text); font-weight: 500;
}
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link .badge { margin-left: auto; }
.main { padding: 1.5rem; max-width: 1400px; width: 100%; min-width: 0; }
.topbar { display: none; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 20;
    padding: calc(env(safe-area-inset-top, 0px) + .6rem) 1rem .6rem; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 1rem 1rem calc(var(--nav-h) + var(--safe-b) + 1.5rem); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--muted); }
  .bottom-nav a svg { width: 24px; height: 24px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a.fab span.fab-btn {
    width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--primary-ink);
    display: grid; place-items: center; margin-top: -22px; box-shadow: var(--shadow);
  }
  .desktop-only { display: none !important; }
}
@media (min-width: 861px) { .mobile-only { display: none !important; } }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.page-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1; min-width: 160px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .6rem 1rem; min-height: 42px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { padding: .5rem; min-width: 42px; }
.btn.sm { min-height: 34px; padding: .35rem .7rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

label.field { display: block; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .62rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; /* verhindert Zoom auf iOS */ min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.input-mic { position: relative; display: flex; gap: .4rem; }
.input-mic input { flex: 1; }
.mic-btn.listening { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5);} 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0);} }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: .88rem; font-weight: 600; cursor: pointer; user-select: none; color: var(--text);
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip.on { background: var(--c, var(--primary)); border-color: var(--c, var(--primary)); color: #fff; }
.chip.on .dot { background: #fff !important; }
.badge { display: inline-block; min-width: 20px; padding: 0 .4rem; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px; }
.badge.gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag { display: inline-block; padding: 0 .45rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: .75rem; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .6rem; border-radius: 10px; cursor: pointer; min-width: 0;
}
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item:hover { background: var(--surface-2); }
.list-item .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.list-item .ico svg { width: 22px; height: 22px; }
.list-item .ico.folder { background: #fef3c7; color: #b45309; }
.list-item .ico.inbox { background: var(--primary-soft); color: var(--primary); }
.list-item .ico.pdf { background: #fee2e2; color: #b91c1c; }
.list-item .ico.img { background: #dbeafe; color: #1d4ed8; }
@media (prefers-color-scheme: dark) {
  .list-item .ico.folder { background: #422006; color: #fbbf24; }
  .list-item .ico.pdf { background: #450a0a; color: #fca5a5; }
  .list-item .ico.img { background: #172554; color: #93c5fd; }
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .s { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; font-size: .9rem; margin-bottom: .75rem; }
.breadcrumbs a { padding: .2rem .4rem; border-radius: 6px; }
.breadcrumbs a:hover { background: var(--surface-2); }
.breadcrumbs .sep { color: var(--muted); }
mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 2px; }
.snippet { font-size: .82rem; color: var(--muted); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fade .15s;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .18s;
}
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.1rem .6rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: .4rem 1.1rem 1rem; overflow: auto; }
.modal-foot { display: flex; gap: .5rem; align-items: center; padding: .8rem 1.1rem calc(.9rem + var(--safe-b)); border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 600px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 18px 18px 0 0; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }

#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
@media (min-width: 861px) { #toasts { bottom: 24px; } }
.toast { background: #0f172a; color: #fff; padding: .65rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; animation: pop .2s; max-width: 90vw; }
.toast.error { background: var(--danger); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; font-size: 1.4rem; padding-bottom: 1.2rem; }
.login-card .brand img { width: 48px; height: 48px; }

/* ---------- Dashboard ---------- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1rem .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 600; font-size: .9rem; text-align: center; box-shadow: var(--shadow); }
.quick a svg { width: 28px; height: 28px; color: var(--primary); }
@media (max-width: 520px) { .quick { grid-template-columns: repeat(2, 1fr); } }
.agenda-day { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .9rem 0 .3rem; }
.agenda-day:first-child { margin-top: 0; }
.agenda-ev { display: flex; gap: .7rem; align-items: stretch; padding: .5rem .4rem; border-radius: 10px; cursor: pointer; }
.agenda-ev:hover { background: var(--surface-2); }
.agenda-ev .bar { width: 5px; border-radius: 3px; flex: none; }
.agenda-ev .time { width: 74px; flex: none; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda-ev .t { font-weight: 600; }
.agenda-ev .who { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .15rem; }
.pdot { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--muted); }
.pdot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

/* ---------- Kalender ---------- */
.cal-toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.cal-toolbar .range { font-weight: 700; font-size: 1.1rem; min-width: 170px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: .5rem .8rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--primary); color: var(--primary-ink); }
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Wochenansicht: Zeilen = Tage, Spalten = Personen */
.wk { --cols: 5; min-width: calc(70px + var(--cols) * 120px); }
.wk-head, .wk-day { display: grid; grid-template-columns: 70px 1fr; }
.wk-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--border); }
.wk-persons, .wk-cells { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.wk-persons > div { padding: .55rem .4rem; text-align: center; font-weight: 700; font-size: .9rem; border-left: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: .35rem; }
.wk-persons > div::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.wk-day { border-bottom: 1px solid var(--border); min-height: 64px; }
.wk-day:last-child { border-bottom: 0; }
.wk-date { padding: .5rem .3rem; text-align: center; border-right: 1px solid var(--border); cursor: pointer; }
.wk-date .wd { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.wk-date .dn { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.wk-day.today .wk-date .dn { color: var(--primary-ink); background: var(--primary); border-radius: 50%; width: 34px; height: 34px; display: inline-grid; place-items: center; }
.wk-day.weekend { background: var(--surface-2); }
.wk-cells { position: relative; align-content: start; padding: 4px 0; row-gap: 4px; }
.wk-bg { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); pointer-events: none; }
.wk-bg > div { border-left: 1px solid var(--border); }
.wk-cells .ev { margin: 0 4px; position: relative; z-index: 1; }
.wk-add { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.wk-add > div { cursor: copy; }

.ev {
  border-radius: 8px; padding: .3rem .5rem; color: #fff; font-size: .82rem; line-height: 1.25; cursor: pointer; overflow: hidden;
  background: var(--bgc); box-shadow: 0 1px 2px rgba(0,0,0,.15); min-width: 0;
}
.ev .et { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .em { opacity: .92; font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.multi { outline: 2px solid rgba(255,255,255,.55); outline-offset: -3px; }
.ev .ico-inline { width: 12px; height: 12px; vertical-align: -1px; }
.ev.split::after { content: "🔗"; position: absolute; right: 4px; top: 3px; font-size: .7rem; }

/* Tagesansicht: Zeitraster mit Personenspalten */
.day { --cols: 5; --hour: 52px; min-width: calc(56px + var(--cols) * 110px); }
.day-head { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); position: sticky; top: 0; background: var(--surface); z-index: 3; border-bottom: 1px solid var(--border); }
.day-head > div { padding: .55rem .3rem; text-align: center; font-weight: 700; font-size: .9rem; border-left: 1px solid var(--border); }
.day-head > div:first-child { border-left: 0; }
.day-allday { display: grid; grid-template-columns: 56px 1fr; border-bottom: 1px solid var(--border); }
.day-allday .lbl { font-size: .7rem; color: var(--muted); padding: .4rem .2rem; text-align: right; }
.day-allday .cells { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); padding: 4px 0; row-gap: 4px; min-height: 34px; }
.day-allday .ev { margin: 0 4px; }
.day-body { display: grid; grid-template-columns: 56px 1fr; position: relative; }
.day-hours > div { height: var(--hour); font-size: .72rem; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-.55em); font-variant-numeric: tabular-nums; }
.day-grid { position: relative; height: calc(24 * var(--hour)); background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% var(--hour); }
.day-grid .colsep { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); }
.day-grid .ev { position: absolute; padding: .2rem .4rem; }
.day-grid .click-layer { position: absolute; inset: 0; cursor: copy; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Monatsansicht */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 560px; }
.month .mh { padding: .5rem; text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.month .md { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .25rem; cursor: pointer; min-width: 0; }
.month .md:nth-child(7n) { border-right: 0; }
.month .md.other { background: var(--surface-2); color: var(--muted); }
.month .md .n { font-size: .85rem; font-weight: 700; padding: .1rem .3rem; display: inline-block; }
.month .md.today .n { background: var(--primary); color: var(--primary-ink); border-radius: 999px; }
.month .mev { font-size: .72rem; padding: 1px 5px; border-radius: 5px; color: #fff; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bgc); }
.month .more { font-size: .72rem; color: var(--muted); padding-left: 4px; }

.person-chips { margin-bottom: .75rem; }
.wd-chips .chip { min-width: 44px; justify-content: center; }
.rem-chips .chip.on, .wd-chips .chip.on { --c: var(--primary); }

/* ---------- Scan ---------- */
.scan-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.scan-page { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 0.72; cursor: pointer; }
.scan-page img { width: 100%; height: 100%; object-fit: contain; display: block; }
.scan-page .num { position: absolute; left: 6px; top: 6px; background: rgba(15,23,42,.75); color: #fff; font-size: .75rem; font-weight: 700; border-radius: 6px; padding: 0 .4rem; }
.scan-add { display: grid; place-items: center; border: 2px dashed var(--border); border-radius: 10px; aspect-ratio: .72; color: var(--muted); cursor: pointer; text-align: center; font-weight: 600; font-size: .85rem; padding: .5rem; }
.scan-add svg { width: 32px; height: 32px; display: block; margin: 0 auto .3rem; }
.crop-wrap { position: relative; touch-action: none; user-select: none; margin: 0 auto; max-width: 100%; }
.crop-wrap canvas { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; }
.crop-wrap svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-handle { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgba(15,118,110,.25); border: 3px solid var(--primary); touch-action: none; cursor: grab; }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--muted); }
.drop-zone.over { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Dokumentvorschau ---------- */
.preview { background: var(--surface-2); border-radius: 10px; overflow: hidden; display: grid; place-items: center; min-height: 200px; }
.preview img { max-width: 100%; max-height: 60vh; display: block; }
.preview iframe { width: 100%; height: 60vh; border: 0; background: #fff; }
.ocr-text { white-space: pre-wrap; font-size: .82rem; max-height: 240px; overflow: auto; background: var(--surface-2); padding: .75rem; border-radius: 10px; }
.doc-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .doc-layout { grid-template-columns: 1fr; } }

/* ---------- Admin ---------- */
table.perm { width: 100%; border-collapse: collapse; }
table.perm td, table.perm th { padding: .4rem .3rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
table.perm select { min-height: 34px; padding: .25rem .4rem; width: auto; }
.tree-indent { display: inline-block; }
.inherit { font-size: .75rem; color: var(--muted); }
.color-input { width: 44px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; }

/* ---------- Ergänzungen ---------- */
.ico-inline { width: 1em; height: 1em; vertical-align: -.12em; display: inline-block; flex: none; }
.chip svg.ico-inline { width: 14px; height: 14px; }

/* Kompakter Kalender auf dem Handy: alle Personen passen nebeneinander */
@media (max-width: 600px) {
  .wk { min-width: 0; }
  .wk-head, .wk-day { grid-template-columns: 40px 1fr; }
  .wk-persons > div { font-size: .72rem; padding: .45rem .1rem; flex-direction: column; gap: 2px; overflow: hidden; }
  .wk-date { padding: .4rem .1rem; }
  .wk-date .dn { font-size: 1.05rem; }
  .wk-day.today .wk-date .dn { width: 28px; height: 28px; }
  .wk-cells .ev { margin: 0 2px; }
  .ev { padding: .2rem .3rem; font-size: .7rem; border-radius: 6px; }
  .ev .et { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; hyphens: auto; }
  .ev .em { font-size: .64rem; }
  .ev.split::after { display: none; }
  .day { min-width: 0; --hour: 48px; }
  .day-head, .day-allday, .day-body { grid-template-columns: 38px 1fr; }
  .day-head { grid-template-columns: 38px repeat(var(--cols), minmax(0, 1fr)); }
  .day-head > div { font-size: .72rem; padding: .45rem .1rem; overflow: hidden; text-overflow: ellipsis; }
  .day-hours > div { font-size: .62rem; padding-right: 3px; }
  .month { min-width: 0; }
  .month .md { min-height: 64px; padding: 2px; }
  .month .mev { font-size: .6rem; padding: 0 3px; }
  .cal-toolbar .range { order: 10; width: 100%; font-size: 1rem; }
  .seg button { padding: .45rem .6rem; }
}
.grid-2 > .card + .card { margin-top: 0; }

/* ---------- Ordnerbaum (Explorer) ---------- */
.tree-card { padding: .5rem; }
.tree-head { display: flex; align-items: center; gap: .4rem; padding: .3rem .4rem .5rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tree-head .btn { min-height: 30px; padding: .15rem .55rem; font-size: .8rem; color: var(--muted); }
.tree-sel { font-size: .92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-sel .sep { color: var(--muted); font-weight: 400; }
.tree-cols { display: grid; grid-template-columns: 1fr 90px 80px; gap: .5rem; padding: .35rem .6rem .35rem 3.1rem; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.tree-cols span:not(:first-child) { text-align: right; }
.tree-body { padding: .25rem 0; }
.tree-row {
  display: grid; grid-template-columns: 22px 20px 1fr 90px 80px; align-items: center; gap: .35rem;
  padding: .22rem .6rem .22rem calc(.3rem + var(--d) * 20px); border-radius: 6px; cursor: pointer; user-select: none; min-height: 32px;
  font-size: .93rem;
}
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--primary-soft); }
.tree-row.active .tree-name { color: var(--primary); font-weight: 700; }
.tree-row.folder .tree-name { font-weight: 600; }
.tree-row.doc .tree-name { font-weight: 400; }
.tree-row.empty-row { cursor: default; min-height: 26px; }
.tree-row.empty-row:hover { background: none; }
.tree-row.drop-over { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.tree-tog { width: 22px; height: 22px; border: 0; background: none; padding: 0; color: var(--muted); display: grid; place-items: center; cursor: pointer; border-radius: 4px; }
.tree-tog:hover { background: var(--border); }
.tree-tog.leaf { cursor: default; background: none; visibility: hidden; }
.tree-tog svg { width: 15px; height: 15px; }
.tree-ico { width: 18px; height: 18px; display: grid; place-items: center; }
.tree-ico svg { width: 17px; height: 17px; }
.tree-ico.folder { color: #d97706; }
.tree-ico.inbox { color: var(--primary); }
.tree-ico.pdf { color: #dc2626; }
.tree-ico.img { color: #2563eb; }
.tree-ico.file { color: var(--muted); }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-tags { margin-left: .3rem; }
.tree-tags .tag { font-size: .68rem; }
.tree-meta { text-align: right; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tree-count { font-size: .72rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 .45rem; line-height: 18px; }
.tree-count.hot { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tree-ro { font-size: .7rem; }
@media (max-width: 860px) {
  .tree-row { grid-template-columns: 24px 20px 1fr auto; min-height: 42px; font-size: .95rem; padding-left: calc(.1rem + var(--d) * 16px); }
  .tree-tags { display: none; }
}

/* ---------- Monat untereinander ---------- */
.month-scroll { overflow: auto; overscroll-behavior: contain; }
.wk.compact .wk-day { min-height: 46px; }
.wk.compact .wk-date { display: flex; align-items: center; justify-content: center; gap: .35rem; padding: .3rem; }
.wk.compact .wk-date .dn { font-size: 1.05rem; }
.wk.compact .wk-day.today .wk-date .dn { width: 30px; height: 30px; }
.wk-sep { padding: .3rem .7rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); }
.wk-sep:first-of-type { border-top: 0; }
.wk-head + .wk-sep { border-top: 0; }
.wk.compact .wk-day.today { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.cal-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; }
.cal-foot .btn:not(.ghost) { min-width: 150px; }
@media (max-width: 600px) {
  .wk.compact .wk-date { flex-direction: column; gap: 0; padding: .25rem .1rem; }
  .cal-foot .btn:not(.ghost) { min-width: 0; flex: 1; }
  .wk.compact .wk-day { min-height: 40px; }
}

/* ---------- Webcam ---------- */
.cam-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; max-height: 62vh; margin: 0 auto; width: 100%; }
.cam-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-guide { position: absolute; inset: 6% 22%; border: 2px dashed rgba(255,255,255,.55); border-radius: 6px; pointer-events: none; }
.cam-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 6rem; font-weight: 800; color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.scan-add.primary { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
@media (max-width: 600px) { .cam-wrap { aspect-ratio: 3 / 4; } .cam-guide { inset: 5% 8%; } }
@media (max-width: 860px) {
  .cal-toolbar { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
  .cal-toolbar .range { order: 0; width: auto; grid-column: 1; grid-row: 1; align-self: center; }
  .cal-toolbar [data-a=new] { grid-column: 2; grid-row: 1; }
  .cal-toolbar .spacer { display: none; }
  .cal-toolbar .cal-views { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(5, 1fr); }
  .cal-toolbar .cal-views button { padding: .45rem .2rem; font-size: .88rem; }
  .page-head h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.25rem; }
  .page-head { flex-wrap: nowrap; }
  .page-head .btn { flex: none; }
}

/* Kategorie-Legende */
.cat-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--muted); margin: -.25rem 0 .75rem; }
.cat-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.cat-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
/* Mehrpersonen-Termine: durchgehend einfarbig, ohne Rahmen-Effekt */
.ev.multi { outline: none; }
@media (max-width: 600px) { .cat-legend { font-size: .7rem; gap: .2rem .6rem; } }
.wk-persons > div::before { display: none; }
.pdot::before { background: var(--c, var(--muted)); }
.list-item > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
