:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #171a21;
  --text-2: #5b6372;
  --text-3: #8a92a0;
  --accent: #4f6bed;
  --accent-text: #ffffff;
  --accent-soft: #eef1fe;
  --danger: #d6453d;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 48px rgba(16,24,40,.18);
  --radius: 10px;

  --s-neu: #7b8494;          --s-neu-bg: #eef0f3;
  --s-in_pruefung: #b7791f;  --s-in_pruefung-bg: #fdf3e1;
  --s-freigegeben: #2f6fd6;  --s-freigegeben-bg: #e6effc;
  --s-in_umsetzung: #7a4fd6; --s-in_umsetzung-bg: #f0eafc;
  --s-umgesetzt: #138a85;    --s-umgesetzt-bg: #e2f5f4;
  --s-getestet: #23883f;     --s-getestet-bg: #e3f4e7;
  --s-abgelehnt: #c4423b;    --s-abgelehnt-bg: #fbe8e7;

  --p-muss: #c4423b; --p-soll: #b7791f; --p-kann: #7b8494;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318; --surface: #191c23; --surface-2: #20242d; --border: #2a2f3a; --border-strong: #3a414f;
    --text: #e8eaee; --text-2: #a3abb9; --text-3: #737c8c;
    --accent: #7088f5; --accent-soft: #232a45;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
    --s-neu: #9aa3b2; --s-neu-bg: #262a33;
    --s-in_pruefung: #e0a54a; --s-in_pruefung-bg: #3a2e1a;
    --s-freigegeben: #6a9cf0; --s-freigegeben-bg: #1c2b45;
    --s-in_umsetzung: #a689f0; --s-in_umsetzung-bg: #2c2445;
    --s-umgesetzt: #3fc0b8; --s-umgesetzt-bg: #163634;
    --s-getestet: #55c271; --s-getestet-bg: #183522;
    --s-abgelehnt: #ec6c64; --s-abgelehnt-bg: #3d1f1d;
    --p-muss: #ec6c64; --p-soll: #e0a54a; --p-kann: #9aa3b2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 650; font-size: 15px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: var(--text-2); cursor: pointer; width: 100%; border: 0; background: none; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 550; }
.nav-item .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.nav-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.main { min-width: 0; padding: 28px 36px 60px; }
.topbar { display: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 680; }
.page-head .sub { color: var(--text-2); margin-top: 4px; max-width: 70ch; white-space: pre-wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.key-chip { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; vertical-align: 3px; margin-left: 8px; }

/* ---------- Buttons / Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 550; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--text-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.prio svg { width: 13px; height: 13px; }
.type-tag { font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 5px; padding: 1px 7px; white-space: nowrap; }
.rid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .v { font-size: 26px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .l { color: var(--text-2); font-size: 13px; }
.section-title { font-size: 15px; font-weight: 650; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .15s, box-shadow .2s, transform .2s;
  display: flex; flex-direction: column; gap: 12px; text-align: left;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-top .sq { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.card-top h3 { font-size: 15px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; margin: 0; }
.card-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.card.archived { opacity: .6; }
.card.new-card { border-style: dashed; align-items: center; justify-content: center; color: var(--text-2); min-height: 150px; background: transparent; }
.card.new-card:hover { color: var(--accent); border-color: var(--accent); }

.stackbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.stackbar > span { height: 100%; transition: flex-grow .4s ease; }
.stackbar.lg { height: 12px; }

/* ---------- Projekt-Ansicht ---------- */
.overview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.overview-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; flex-wrap: wrap; }
.overview-top .pct { font-size: 22px; font-weight: 680; font-variant-numeric: tabular-nums; }
.overview-top .pct small { font-size: 13px; color: var(--text-2); font-weight: 500; margin-left: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.legend button {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 3px 10px 3px 8px; cursor: pointer; font-size: 12.5px; color: var(--text-2);
  transition: border-color .15s, background .15s;
}
.legend button:hover { border-color: var(--border-strong); }
.legend button.on { border-color: currentColor; background: var(--surface-2); color: var(--text); }
.legend .sw { width: 8px; height: 8px; border-radius: 50%; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--text-3); }
.toolbar .search .input { padding-left: 34px; }
.toolbar select.input { width: auto; min-width: 130px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 0 12px; height: 28px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.seg button svg { width: 15px; height: 15px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Tabelle */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.reqs { width: 100%; border-collapse: collapse; }
table.reqs th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); cursor: pointer; user-select: none; white-space: nowrap; }
table.reqs th:hover { color: var(--text); }
table.reqs th .arr { opacity: .7; margin-left: 3px; }
table.reqs td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.reqs tr:last-child td { border-bottom: 0; }
table.reqs tbody tr { cursor: pointer; transition: background .12s; }
table.reqs tbody tr:hover { background: var(--surface-2); }
table.reqs .t-title { font-weight: 550; }
table.reqs .t-title .c { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: 6px; }
.status-select {
  appearance: none; border: 0; cursor: pointer; font-size: 12px; font-weight: 600; border-radius: 999px;
  height: 24px; padding: 0 22px 0 10px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 12px;
}

/* Board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 140px; transition: background .15s, box-shadow .15s; }
.col.drop { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; font-size: 13px; }
.col-head .sw { width: 9px; height: 9px; border-radius: 50%; }
.col-head .n { color: var(--text-3); font-weight: 500; }
.col-head .add { margin-left: auto; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.bcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  cursor: grab; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s, opacity .15s, transform .15s;
}
.bcard:hover { border-color: var(--border-strong); }
.bcard.dragging { opacity: .4; }
.bcard .bt { font-weight: 550; line-height: 1.35; overflow-wrap: anywhere; }
.bcard .bm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bcard .bm .rid { margin-right: auto; }

.empty { text-align: center; padding: 56px 20px; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty p { margin: 0 0 16px; }

/* ---------- Drawer / Modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,12,18,.38); z-index: 40; animation: fade .18s ease-out; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface);
  z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slidein .26s cubic-bezier(.2,.8,.2,1);
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head .rid { font-size: 13px; }
.drawer-head .sp { flex: 1; }
.drawer-body { padding: 20px 22px 30px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.title-input { font-size: 20px; font-weight: 650; border: 0; outline: none; width: 100%; background: transparent; padding: 4px 0; margin-bottom: 14px; resize: none; line-height: 1.3; }
.title-input::placeholder { color: var(--text-3); }
.props { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; margin-bottom: 18px; }
.props .field { margin: 0; }

.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); width: min(500px, calc(100vw - 32px));
  background: var(--surface); border-radius: 14px; z-index: 41; box-shadow: var(--shadow-lg); padding: 22px;
  animation: pop .2s cubic-bezier(.2,.8,.2,1); max-height: 80vh; overflow-y: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }
.modal-actions .r { display: flex; gap: 8px; margin-left: auto; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 26px; height: 26px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; transition: transform .12s; }
.colors button:hover { transform: scale(1.1); }
.colors button.on { border-color: var(--text); }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 26px; bottom: -8px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .ic { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border-strong); flex: none; margin-top: 3px; position: relative; z-index: 1; }
.timeline .tx { flex: 1; font-size: 13px; color: var(--text-2); min-width: 0; }
.timeline .tx b { color: var(--text); font-weight: 600; }
.timeline .when { font-size: 12px; color: var(--text-3); }
.timeline .cm { background: var(--surface-2); border-radius: 8px; padding: 8px 11px; color: var(--text); margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .del { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 12px; padding: 0; margin-left: 8px; }
.timeline .del:hover { color: var(--danger); }
.comment-box { display: flex; gap: 8px; margin: 10px 0 14px; align-items: flex-end; }
.comment-box textarea { min-height: 40px; height: 40px; }
.h-section { font-size: 13px; font-weight: 650; margin: 24px 0 8px; color: var(--text); }

/* Login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login .brand { padding: 0 0 18px; font-size: 17px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 6px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 9px; font-weight: 550; z-index: 60;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translateX(-50%) scale(.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 45; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .layout.nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; }
  .main { padding: 18px 16px 50px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  .props, .field-row { grid-template-columns: 1fr; }
  .input, select.input, textarea.input { font-size: 16px; }
  .toolbar select.input { flex: 1; min-width: 0; }
  table.reqs td, table.reqs th { padding: 10px; }
}
@media (hover: none) { .card:hover, .bcard:hover { border-color: var(--border); box-shadow: none; } }

/* ---------- Anfragen ---------- */
.origin-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px 1px 5px; margin-right: 8px; vertical-align: 1px; white-space: nowrap; }
.origin-tag svg { width: 12px; height: 12px; }
.bcard .origin-tag { margin: 0; }
.submitter { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border-radius: 9px; padding: 11px 13px; margin-bottom: 16px; font-size: 13.5px; }
.submitter > svg { width: 17px; height: 17px; color: var(--accent); flex: none; margin-top: 2px; }
.intake-box { background: var(--surface-2); border-radius: 10px; padding: 14px; margin-top: 4px; }
.intake-more { margin-top: 12px; }
.intake-more[hidden] { display: none; }
.linkrow { display: flex; gap: 6px; }
.linkrow .input { font-size: 13px; background: var(--surface); }
.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background-color .2s ease; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .22s cubic-bezier(.23,1,.32,1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
