:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bug: #dc2626;
  --bug-soft: #fef2f2;
  --feat: #7c3aed;
  --feat-soft: #f5f3ff;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.18);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger { background: var(--bug); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 38px 34px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 21px; margin: 10px 0 4px; }
.login-sub { color: var(--text-soft); margin: 0 0 22px; font-size: 14px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.role-toggle { display: flex; gap: 10px; }
.role-opt {
  flex: 1; margin: 0 !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 8px !important;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.role-opt input { display: none; }
.role-opt:has(input:checked) { border-color: var(--primary); background: #eff6ff; color: var(--primary-dark); font-weight: 700; }
.pw-box small { color: var(--text-soft); font-size: 12px; display: block; margin-top: 6px; }
.alert {
  background: var(--bug-soft); color: var(--bug);
  border: 1px solid #fecaca; border-radius: 10px;
  padding: 10px 14px; font-size: 14px; margin-bottom: 14px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 28px; }
.brand h1 { font-size: 18px; margin: 0; }
.brand-sub { font-size: 12.5px; color: #94a3b8; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; font-size: 14px; }
.badge {
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
.badge-admin { background: #fde68a; color: #92400e; }
.badge-dev { background: #bfdbfe; color: #1e40af; }
.topbar .btn-ghost { border-color: #334155; color: #cbd5e1; }
.topbar .btn-ghost:hover { background: #1e293b; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 10px; align-items: center; }
.filters input[type="search"], .filters select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.filters input[type="search"] { min-width: 200px; }

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 24px 40px;
  align-items: start;
}
.column {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}
.column-bugs { border-top: 4px solid var(--bug); }
.column-features { border-top: 4px solid var(--feat); }
.col-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.col-head h2 { font-size: 17px; margin: 0; }
.col-flag {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--bug); background: var(--bug-soft);
  padding: 3px 8px; border-radius: 6px; letter-spacing: .03em;
}
.col-count {
  margin-left: auto;
  background: var(--surface-2);
  color: var(--text-soft);
  font-weight: 700; font-size: 13px;
  min-width: 26px; text-align: center;
  padding: 2px 8px; border-radius: 20px;
}
.card-list { display: flex; flex-direction: column; gap: 12px; }
.empty-hint { color: var(--text-soft); font-size: 14px; text-align: center; padding: 18px 0; }

/* ---------- Card ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow); }
.card.done { opacity: .62; background: var(--surface-2); }
.card.done .card-title { text-decoration: line-through; }
.card-prio-left { border-left: 4px solid var(--border); }
.card.prio-kritisch { border-left: 4px solid #dc2626; }
.card.prio-hoch { border-left: 4px solid #ea580c; }
.card.prio-mittel { border-left: 4px solid #eab308; }
.card.prio-niedrig { border-left: 4px solid #22c55e; }

.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-check {
  width: 20px; height: 20px; margin-top: 2px;
  cursor: pointer; flex-shrink: 0; accent-color: var(--ok);
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; word-wrap: break-word; }
.card-desc { color: #334155; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; margin: 4px 0 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-soft);
}
.chip-prio-kritisch { background: #fee2e2; color: #b91c1c; }
.chip-prio-hoch { background: #ffedd5; color: #c2410c; }
.chip-prio-mittel { background: #fef9c3; color: #a16207; }
.chip-prio-niedrig { background: #dcfce7; color: #15803d; }
.chip-status-offen { background: #e2e8f0; color: #475569; }
.chip-status-in_arbeit { background: #dbeafe; color: #1d4ed8; }
.chip-status-erledigt { background: #dcfce7; color: #15803d; }

.card-meta { font-size: 12px; color: var(--text-soft); margin-top: 6px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-weight: 600; font-size: 13px;
  padding: 4px 6px; border-radius: 6px; font-family: inherit;
}
.link-btn:hover { background: var(--surface-2); }
.link-btn.danger { color: var(--bug); }
.status-btn {
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: #fff;
  padding: 4px 10px; border-radius: 8px; font-family: inherit;
}
.status-btn:hover { background: var(--surface-2); }

/* ---------- Comments ---------- */
.comments { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.comment {
  background: var(--surface-2);
  border-radius: 9px;
  padding: 8px 11px;
  margin-bottom: 7px;
  font-size: 13.5px;
}
.comment-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.comment-author { font-weight: 700; font-size: 12.5px; }
.comment-time { color: var(--text-soft); font-size: 11.5px; }
.comment-text { margin-top: 3px; white-space: pre-wrap; word-wrap: break-word; }
.comment-del {
  background: none; border: none; color: var(--bug);
  cursor: pointer; font-size: 11px; padding: 0; opacity: .6;
}
.comment-del:hover { opacity: 1; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input {
  flex: 1; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 13.5px; font-family: inherit;
}
.comment-form input:focus { outline: none; border-color: var(--primary); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text-soft);
}
.modal form { padding: 20px 22px; }
.modal label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.modal label:first-of-type { margin-top: 0; }
.modal input[type="text"], .modal textarea, .modal select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14.5px; font-family: inherit;
}
.modal textarea { resize: vertical; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--primary); }
.type-toggle, .role-toggle { display: flex; gap: 10px; }
.type-opt {
  flex: 1; margin: 0 !important;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 8px !important; text-align: center;
  cursor: pointer; font-size: 14px; transition: all .15s;
}
.type-opt input { display: none; }
.type-opt.type-bug:has(input:checked) { border-color: var(--bug); background: var(--bug-soft); color: var(--bug); font-weight: 700; }
.type-opt.type-feat:has(input:checked) { border-color: var(--feat); background: var(--feat-soft); color: var(--feat); font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg); color: #fff;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 200;
  font-size: 14px; font-weight: 500;
}
.toast.err { background: var(--bug); }

/* ---------- Vorschläge-Bereich ---------- */
.board-wrap { padding: 0 24px 40px; }
.board-wrap .board { padding: 0; }
.suggestions {
  background: var(--feat-soft);
  border: 1px solid #ddd6fe;
  border-top: 4px solid var(--feat);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.flag-vorschlag { color: var(--feat); background: #ede9fe; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card-suggestion { border-left: 4px solid var(--feat); }
.await-hint { font-size: 12.5px; color: var(--text-soft); font-style: italic; }

/* ---------- Chips: Typ + neue Status ---------- */
.chip-type { background: #e0e7ff; color: #3730a3; }
.chip-status-vorgeschlagen { background: #ede9fe; color: #6d28d9; }
.chip-status-abgelehnt { background: #fee2e2; color: #b91c1c; }

/* ---------- Karten-Zustände ---------- */
.card.rejected { opacity: .6; background: var(--surface-2); }
.card.rejected { border-left-color: #cbd5e1 !important; }
.card.rejected .card-title { text-decoration: line-through; }

/* ---------- Drag & Drop ---------- */
.drag-handle {
  cursor: grab; color: var(--text-soft); font-size: 18px; line-height: 1;
  padding: 2px 4px 0 0; user-select: none; flex-shrink: 0;
}
.card.dragging { opacity: .5; box-shadow: var(--shadow-lg); }

/* ---------- kleine Buttons ---------- */
.mini-btn {
  margin-left: 8px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; color: var(--text-soft);
}
.mini-btn:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #15803d; }
.btn-reject { background: #fff; color: var(--bug); border-color: #fecaca; }
.btn-reject:hover { background: var(--bug-soft); }
.link-btn.ok { color: var(--ok); }

/* ---------- Admin-only: nur fürs Team (GuestAI) sichtbar ---------- */
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .board { grid-template-columns: 1fr; }
  .board-wrap { padding: 0 14px 30px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters { flex-wrap: wrap; }
  .filters input[type="search"] { flex: 1; min-width: 0; }
}
