:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #1b2236;
  --muted: #6a7389;
  --primary: #2563eb;
  --primary-dark: #1d4fc4;
  --danger: #d93025;
  --border: #e2e6f0;
  --radius: 14px;
  --title-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --title-size: 14px;
  --time-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --time-size: 12px;
  --footer-h: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.error { color: var(--danger); font-size: 13px; margin: 6px 0; }
.spacer { flex: 1; }
.icon { display: inline-flex; flex: none; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.shell { flex: 1; display: flex; min-height: 0; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  width: 58px;
  flex: none;
  background: var(--card);
  border-right: 1px solid var(--border);
}
.nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  min-height: calc(100dvh - var(--footer-h));
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.nav-btn:hover { background: #eef2fb; color: var(--primary); }
.nav-label { display: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}
.app-title { font-size: 20px; font-weight: 600; letter-spacing: .2px; }
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 600;
}
.user-name { font-weight: 500; }

.content { flex: 1; padding: 4px 16px 90px; }

.footer {
  min-height: var(--footer-h);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 24px;
  padding: 8px 16px;
  background: #000;
  color: #fff;
  font-size: 13px;
}
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer a { color: #fff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: #eef2fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f1c4c0; }
.btn-danger:hover:not(:disabled) { background: #fdecea; }
.btn.wide { width: 100%; margin-top: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
.icon-btn.danger { color: var(--danger); }
.burger { display: none; width: 38px; height: 38px; color: var(--text); }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--footer-h) + 18px);
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--primary); color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .45);
  cursor: pointer;
  z-index: 20;
}
.fab:hover { background: var(--primary-dark); }

/* ---------- Kalender ---------- */
.toolbar { display: flex; justify-content: flex-end; padding: 0 0 10px; }
.toolbar select { width: auto; padding: 5px 8px; }

.days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}
.day {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 10px 12px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
.day.today { box-shadow: 0 0 0 2px var(--primary), 0 1px 3px rgba(20, 30, 60, .08); }
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.day-head .icon { color: var(--muted); }
.day-events { display: flex; flex-direction: column; gap: 8px; }

.event {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 7px 6px 7px 10px;
  border-radius: 9px;
  background: var(--ev-bg);
  border-left: 4px solid var(--ev-accent);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.event-main { flex: 1; min-width: 0; }
.event-title {
  font-family: var(--title-font);
  font-size: var(--title-size);
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}
.event-time {
  font-family: var(--time-font);
  font-size: var(--time-size);
  color: var(--muted);
  margin-top: 1px;
}
.event-meta { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.event-meta .event-time { margin-top: 0; }
.badge {
  padding: 0 6px; border-radius: 6px;
  background: rgba(255, 255, 255, .7); color: hsl(212 80% 38%);
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
}
.empty { color: var(--muted); padding: 24px 4px; max-width: 460px; }

/* ---------- Login & statische Seiten ---------- */
.login-wrap { display: grid; place-items: start center; padding-top: 6vh; }
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
.login-card h2 { margin-bottom: 14px; font-size: 20px; }

.static-wrap { max-width: 800px; }
.static-page {
  margin-top: 12px;
  padding: 18px 22px;
  background: var(--card);
  border-radius: var(--radius);
  line-height: 1.6;
}

/* ---------- Formulare ---------- */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; flex: 1; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.check input { width: auto; }

.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; margin-top: 8px; }
.status { margin-top: 10px; font-size: 13px; }
.status.error { color: var(--danger); }
.file-list { margin: 10px 0 0; padding-left: 18px; max-height: 30vh; overflow: auto; font-size: 13px; }
.file-list .error { color: var(--danger); }

/* ---------- Combobox ---------- */
.combo { position: relative; display: flex; }
.combo-input { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.combo-toggle {
  flex: none; width: 36px;
  border: 1px solid var(--border); border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #f6f8fc; color: var(--muted); cursor: pointer;
}
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  z-index: 30;
  margin: 0; padding: 4px; list-style: none;
  max-height: 40vh; overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 30, 60, .18);
}
.combo-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.combo-list li:hover, .combo-list li.active { background: #eaf0fe; }
.combo-name { overflow-wrap: anywhere; }
.combo-hint { flex: none; font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- Dialoge ---------- */
dialog.dlg {
  border: 0; border-radius: 16px; padding: 0;
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow: auto;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(10, 20, 50, .35);
}
dialog.dlg::backdrop { background: rgba(15, 23, 42, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.dlg-head h2 { font-size: 18px; }
.dlg-body { padding: 14px 18px 18px; }
.dlg-body h3 { font-size: 14px; margin: 4px 0 8px; }

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--footer-h) + 18px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 100; pointer-events: none;
}
.toast { padding: 9px 16px; border-radius: 10px; background: #1b2236; color: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); max-width: 90vw; }
.toast.error { background: var(--danger); }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  .burger { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .content { padding: 4px 12px 90px; }
  .user-name { display: none; }
  .user-pill { padding: 3px; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 270px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .2);
  }
  body.drawer-open .sidebar { transform: none; }
  .nav { position: static; min-height: 100%; padding: 16px 10px; }
  .nav-btn { width: 100%; justify-content: flex-start; padding: 0 12px; }
  .nav-label { display: inline; }
  .overlay { display: none; }
  body.drawer-open .overlay { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; }
  .days { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
