:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ec;
  --text: #1c2434;
  --muted: #606f86;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  text-align: center;
}
.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.login-card form { text-align: left; margin-top: 1.25rem; }
.hint-text { font-size: 0.8rem; color: var(--muted); margin-top: 1.25rem; }

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}
.sync-pill {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-weight: 600;
}
.sync-pill.offline {
  background: var(--warn-bg);
  color: var(--warn);
}
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn:hover { background: var(--bg); color: var(--text); }
.tab-btn.active { background: #eff6ff; color: var(--primary); font-weight: 600; }

.user-chip {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  background: var(--bg);
  border-radius: 999px;
}

/* Layout */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.panel-header h2 { margin: 0; font-size: 1.3rem; }
.panel-header p { margin: 0.2rem 0 0; font-size: 0.9rem; }

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(15, 23, 42, 0.06); color: var(--text); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  margin-top: 0.28rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
}
textarea { min-height: 75px; resize: vertical; }
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.filter-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.seg-btn.active { background: var(--primary); color: #fff; }

/* Color Legend */
.color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 0.85rem;
  font-size: 0.83rem;
  color: var(--muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}
.swatch-white { background: #ffffff; border: 2px solid #94a3b8; }
.swatch-blue { background: #eff6ff; border: 2px solid #2563eb; }
.swatch-red { background: #fef2f2; border: 2px solid #dc2626; }

/* Task List & Color Coding */
.task-list { display: flex; flex-direction: column; gap: 0.65rem; }
.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid #94a3b8;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.task-item.task-color-white {
  background: #ffffff;
  border-color: #cbd5e1;
  border-left-color: #94a3b8;
}
.task-item.task-color-blue {
  background: #eff6ff;
  border-color: #bfdbfe;
  border-left-color: #2563eb;
}
.task-item.task-color-red {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: #dc2626;
}
.task-item.done { opacity: 0.62; }
.task-item.done .task-title { text-decoration: line-through; }

.task-item.draggable { cursor: grab; }
.task-item.dragging { opacity: 0.45; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14); }
.task-item.drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }

.drag-handle {
  color: #94a3b8;
  font-size: 1.05rem;
  line-height: 1.4;
  user-select: none;
  cursor: grab;
  padding: 0 0.15rem;
  flex-shrink: 0;
}
.drag-handle:hover { color: var(--text); }

.task-check {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--ok);
  flex-shrink: 0;
}
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 1rem; margin: 0 0 0.2rem; }
.task-desc { margin: 0 0 0.45rem; font-size: 0.9rem; color: #334155; white-space: pre-wrap; }
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.8rem;
}
.task-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.move-btn {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.75);
  color: #334155;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}
.move-btn:hover:not(:disabled) { background: #fff; border-color: var(--primary); color: var(--primary); }
.move-btn:disabled { opacity: 0.35; cursor: default; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.75);
  color: #334155;
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.badge-danger { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.badge-blue { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-self { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.badge-kollegium { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.badge-leitung { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* Cards */
.card-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.card-title { font-weight: 700; font-size: 1rem; margin: 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.35rem;
  background: var(--bg);
  padding: 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
}
.section-sub {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.9rem 0 0.35rem;
  color: #334155;
}

/* Logs */
.log-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 480px; overflow-y: auto; }
.log-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.83rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.modal-header h3 { margin: 0; }
.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-bottom: 0.75rem;
}
.info-box {
  background: #eff6ff;
  color: var(--primary);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-top: 0.75rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #1e293b;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 9px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0.6rem 0.75rem; }
  .task-item { flex-wrap: wrap; }
}
