:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sidebar: #172b4d;
  --sidebar-text: #c7d1e0;
  --text: #172b4d;
  --muted: #6b778c;
  --border: #dfe1e6;
  --primary: #0c66e4;
  --primary-hover: #0055cc;
  --danger: #c9372c;
  --high: #c9372c;
  --medium: #b38600;
  --low: #22a06b;
  --panel-width: 500px;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
a { color: var(--primary); text-decoration: none; }
kbd { font: 11px/1 inherit; border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; background: #fafbfc; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=color]), select, textarea {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea { width: 100%; resize: vertical; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.count { color: var(--muted); font-size: 12px; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; display: inline-block; color: var(--text);
}
.btn:hover { background: #f1f2f4; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; }
.link:hover { text-decoration: underline; }
.icon-btn {
  background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 15px;
  width: 26px; height: 26px; border-radius: 4px; line-height: 1;
}
.icon-btn:hover { background: rgba(9, 30, 66, .08); color: var(--text); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.home-btn { position: relative; display: block; width: calc(100% - 2px); margin: 0 -10px 14px auto; border-radius: var(--radius); overflow: hidden; background: transparent; }
.home-btn img { display: block; width: 100%; height: auto; }
.home-btn .on { position: absolute; inset: 0; opacity: 0; }
.home-btn:hover .on, .home-btn.active .on { opacity: 1; }
.home-btn:hover .off, .home-btn.active .off { opacity: 0; }
.brand { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.25; padding: 4px 10px 18px; display: block; }
.brand span, .auth-brand span { display: block; font-weight: 400; opacity: .7; }
.nav {
  color: var(--sidebar-text); display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius);
}
.nav:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.nav .count { margin-left: auto; color: inherit; opacity: .7; }
.nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-title {
  display: flex; align-items: center; justify-content: space-between; margin: 18px 10px 4px;
  text-transform: uppercase; font-size: 11px; letter-spacing: .05em; opacity: .7;
}
.nav-title .icon-btn { color: var(--sidebar-text); }
.nav-title .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.spacer { flex: 1; min-height: 20px; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 8px; }
.me .link { color: var(--sidebar-text); margin-left: auto; font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 20px 28px 40px; transition: margin-right .15s; }
@media (min-width: 1300px) { body.panel-open .main { margin-right: var(--panel-width); } }

.page-head { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 12px; border-radius: var(--radius); color: var(--muted); font-weight: 500; }
.tab:hover { background: rgba(9, 30, 66, .06); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(9, 30, 66, .15); }

.section { margin-bottom: 28px; }
.empty-state { color: var(--muted); padding: 40px; text-align: center; }

/* ---------- Filter ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { width: 280px; }

/* ---------- Kleine Bausteine ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font-size: 10px; font-weight: 700; flex-shrink: 0; vertical-align: middle;
}
.label {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white);
}
.labels { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.type { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.type-bug { background: #ffeceb; color: #ae2e24; }
.type-correction { background: #fff3d6; color: #7f5f01; }
.type-finding { background: #e9f2ff; color: #0055cc; }
.type-idea { background: #dcfff1; color: #216e4e; }
.prio { font-size: 11px; font-weight: 600; white-space: nowrap; }
.prio::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.prio-high { color: var(--high); } .prio-high::before { background: var(--high); }
.prio-medium { color: var(--medium); } .prio-medium::before { background: var(--medium); }
.prio-low { color: var(--low); } .prio-low::before { background: var(--low); }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--danger); font-weight: 600; }
.num { color: var(--muted); font-size: 12px; font-weight: 600; }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; }
.column { background: #ebecf0; border-radius: 8px; padding: 8px; }
.column header {
  display: flex; justify-content: space-between; padding: 4px 6px 10px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.cards { min-height: 80px; display: flex; flex-direction: column; gap: 8px; border-radius: 6px; transition: background .1s; }
.cards.drop-target { background: rgba(12, 102, 228, .1); outline: 2px dashed rgba(12, 102, 228, .4); }
.empty { color: var(--muted); font-size: 12px; text-align: center; padding: 20px 0; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 10px; cursor: pointer;
  box-shadow: 0 1px 1px rgba(9, 30, 66, .2); border-left: 3px solid transparent; display: flex; flex-direction: column; gap: 6px;
}
.card:hover { background: #fafbfc; }
.card.prio-high { border-left-color: var(--high); }
.card.selected { outline: 2px solid var(--primary); }
.card.dragging { opacity: .4; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-title { font-weight: 500; line-height: 1.35; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.card .proj { font-size: 11px; color: var(--muted); background: #f1f2f4; border-radius: 3px; padding: 0 5px; }
.archive-btn { align-self: flex-start; }

/* ---------- Liste ---------- */
.table-wrap { background: var(--surface); border-radius: 8px; box-shadow: 0 1px 1px rgba(9, 30, 66, .2); overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; color: var(--muted); padding: 10px; border-bottom: 2px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.list td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f7f8f9; }
table.list tbody tr.selected { background: #e9f2ff; }
.title-cell { font-weight: 500; min-width: 240px; }

/* ---------- Übersicht ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
  background: var(--surface); border-radius: 8px; padding: 16px; color: var(--text);
  box-shadow: 0 1px 1px rgba(9, 30, 66, .2); display: flex; flex-direction: column; gap: 12px;
}
.project-card:hover { box-shadow: 0 4px 10px rgba(9, 30, 66, .15); }
.project-card h3 { margin: 0; font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div { display: flex; flex-direction: column; align-items: center; background: var(--bg); border-radius: 6px; padding: 6px 2px; }
.stats b { font-size: 18px; }
.stats span { font-size: 11px; color: var(--muted); }
.flags { display: flex; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.flag { font-size: 11px; font-weight: 600; border-radius: 10px; padding: 2px 8px; }
.flag.high { background: #ffeceb; color: var(--high); }
.flag.overdue { background: #fff3d6; color: #7f5f01; }
.mine { background: var(--surface); border-radius: 8px; box-shadow: 0 1px 1px rgba(9, 30, 66, .2); }
.mine-row { display: flex; gap: 12px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mine-row:last-child { border-bottom: 0; }
.mine-row:hover { background: #f7f8f9; }
.mine-title { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Seitenpanel ---------- */
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-width); max-width: 100vw; background: var(--surface);
  box-shadow: -4px 0 16px rgba(9, 30, 66, .15); display: flex; flex-direction: column; z-index: 10;
}
#panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.title-input { font-size: 18px; font-weight: 600; width: 100%; border-color: transparent !important; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px); }
.title-input:hover { background: #f7f8f9; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid label, .stack-form label, .auth-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.grid select, .grid input { color: var(--text); font-weight: 400; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.label-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.label.pick { cursor: pointer; opacity: .45; font-family: inherit; }
.label.pick.on { opacity: 1; box-shadow: 0 0 0 1px var(--c); }
.dropzone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px;
}
.dropzone.active { border-color: var(--primary); background: #e9f2ff; color: var(--primary); }
.attachments { display: flex; flex-direction: column; gap: 8px; }
.attachment { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.attachment img { width: 96px; height: 64px; object-fit: cover; border-radius: 4px; display: block; background: var(--bg); }
.attachment.has-image { flex-wrap: wrap; }
.attachment.has-image > a:first-child { flex-basis: 100%; }
.attachment.has-image img { width: 100%; height: auto; max-height: 260px; object-fit: contain; background: var(--bg); }
.file-icon { width: 96px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 26px; background: var(--bg); border-radius: 4px; }
.att-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-info a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment { border-left: 2px solid var(--border); padding: 2px 0 2px 10px; }
.comment-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.comment-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.field .btn.small { align-self: flex-start; }
.history summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.history-row { font-size: 12px; padding: 4px 0; border-bottom: 1px solid #f1f2f4; }
.panel-actions { display: flex; gap: 8px; }

/* ---------- Einstellungen ---------- */
.settings { background: var(--surface); border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 1px rgba(9, 30, 66, .2); max-width: 820px; }
table.plain { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.plain td { padding: 7px 0; border-bottom: 1px solid #f1f2f4; }
table.plain td.actions { text-align: right; white-space: nowrap; }
table.plain td.actions > * { margin-left: 4px; vertical-align: middle; }
input[type=color] { width: 32px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; vertical-align: middle; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input:not([type=color]) { flex: 1; max-width: 360px; }
.stack-form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.stack-form .btn { align-self: flex-start; }
.invite { margin-top: 8px; }
.invite-link { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invite-link input { flex: 1; min-width: 260px; font-family: ui-monospace, monospace; font-size: 12px; }
.invite-link p { flex-basis: 100%; margin: 0; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: #bed3e0; }
.auth-box {
  background: rgba(255, 255, 255, .35); border: 2px solid rgba(255, 255, 255, .6); border-radius: 24px;
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  padding: 40px 32px 32px; width: 420px; max-width: 100%;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 8px 32px rgba(23, 43, 77, .12);
}
.auth-box h1 { font-size: 16px; font-weight: 300; text-align: center; margin: 0; }
.auth-box p { margin: 0; }
.auth-box input { color: var(--text); font-weight: 400; font-size: 14px; }
.auth-box input:focus { outline: 2px solid #028caf; border-color: transparent; }
.auth-box .btn { font-size: 13px; }
.auth-box .btn.primary { padding: 9px; background: #028caf; border-color: #028caf; }
.auth-box .btn.primary:hover { background: #017a99; border-color: #017a99; }
.auth-box .link { align-self: center; }
.back-link { align-self: center; font-size: 13px; color: var(--muted); }
.back-link:hover { color: var(--text); }
.auth-logo { display: block; max-width: 220px; max-height: 120px; margin: 0 auto 24px; }
.form-error { color: var(--danger); font-size: 13px; }

/* ---------- Meldungen ---------- */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #172b4d; color: #fff;
  padding: 10px 16px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); z-index: 20; font-size: 13px;
}
#toast.error { background: var(--danger); }
#toast[hidden] { display: none; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main { padding: 16px; }
  .board { grid-template-columns: repeat(4, 260px); }
  .grid { grid-template-columns: 1fr; }
}

/* ---------- Screenshot-Popup ---------- */
#lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(23, 43, 77, .82); display: flex; flex-direction: column; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: #fff; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 16px 16px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
