:root {
  --bg: #f5f6f8; --card: #fff; --text: #1a1d23; --muted: #6b7280; --line: #e3e6ea; --accent: #1f5fbf; --accent-soft: #e8f0fc;
  --s-offen: #d9dde3; --s-in_arbeit: #3b82f6; --s-blockiert: #ef4444; --s-erledigt: #22c55e;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; }
.muted { color: var(--muted); }
.error { color: #b91c1c; font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; color: var(--text); }
.btn:hover { background: #f1f3f6; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 8px; padding: 9px 14px; border-style: solid; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #b91c1c; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eceff3; }

/* Login */
main.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
main.login .card { width: 100%; max-width: 360px; }
main.login .card h1 { margin-bottom: 2px; }
main.login .card p { margin: 0 0 16px; }
main.login button { width: 100%; margin-top: 6px; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding: 0 16px; display: flex; align-items: center; gap: 14px; height: 54px; }
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; color: var(--text); }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar .spacer { flex: 1; }
.bell { position: relative; }
.bell .badge { position: absolute; top: -4px; right: -4px; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 5px; min-width: 17px; text-align: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }

.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page.wide { max-width: none; }

/* Filter bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; }
.filters input[type=search] { min-width: 220px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }
.tabs button .n { opacity: .6; margin-left: 4px; font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin: 0; }
.check input { width: auto; margin: 0; }

/* Matrix */
.section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.section header { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.section header h2 { margin: 0; }
.section header .sum { color: var(--muted); font-size: 13px; }
.scroll { overflow: visible; }
@media (max-width: 1000px) { .scroll { overflow-x: auto; } table.matrix thead th { top: 0; } }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.matrix th, table.matrix td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; vertical-align: middle; }
table.matrix thead th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 54px; z-index: 5; }
table.matrix th.step, table.matrix td.step { text-align: center; width: 54px; min-width: 54px; }
table.matrix th.step { white-space: normal; line-height: 1.15; vertical-align: bottom; padding-bottom: 8px; }
table.matrix .num { color: var(--muted); width: 48px; font-variant-numeric: tabular-nums; }
table.matrix .title { position: sticky; left: 0; background: #fff; z-index: 2; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.matrix thead .title { z-index: 6; background: #fafbfc; }
table.matrix .title a { color: var(--text); font-weight: 500; }
table.matrix .title a:hover { color: var(--accent); }
table.matrix tr.hold td { opacity: .5; }
table.matrix tr.hold td.title a::after { content: "Pause"; margin-left: 8px; font-size: 11px; color: #92400e; background: #fef3c7; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
table.matrix tr.archived td { opacity: .45; }
table.matrix tr:hover td { background: #f8fafc; }
table.matrix tr:hover td.title { background: #f8fafc; }
.cell { display: inline-block; width: 26px; height: 26px; border-radius: 7px; border: none; background: var(--s-offen); vertical-align: middle; }
.cell.in_arbeit { background: var(--s-in_arbeit); }
.cell.blockiert { background: var(--s-blockiert); }
.cell.erledigt { background: var(--s-erledigt); }
.cell.none { background: transparent; border: 1px dashed var(--line); cursor: default; }
.cell:not(.none):hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.cell.has-note::after { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; background: #fff; margin: 10px auto 0; opacity: .9; }
.prog { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prog .bar { width: 70px; height: 6px; background: #e9ecf0; border-radius: 999px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--s-erledigt); }
.prio { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.prio.hoch { background: #ef4444; } .prio.mittel { background: #f59e0b; } .prio.niedrig { background: #9ca3af; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef1f5; color: #374151; }
.chip.user { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 14px; height: 14px; border-radius: 4px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Popover */
.popover { position: absolute; z-index: 50; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 8px; min-width: 190px; }
.popover .ttl { font-size: 12px; color: var(--muted); padding: 2px 6px 6px; max-width: 240px; white-space: normal; }
.popover button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; background: none; padding: 7px 8px; border-radius: 7px; }
.popover button:hover { background: #f1f3f6; }
.popover button.active { background: var(--accent-soft); font-weight: 600; }
.popover hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* Detail */
.detail-head { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.detail-head h1 .num { color: var(--muted); font-weight: 500; margin-right: 8px; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 4px; }
.meta b { color: var(--text); font-weight: 500; }
.path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #eef1f5; padding: 2px 8px; border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { border-bottom: 1px solid var(--line); padding: 10px 16px; }
.steps li:last-child { border-bottom: none; }
.steps .main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.steps .pos { width: 24px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.steps .name { font-weight: 500; min-width: 190px; }
.steps .name.erledigt { color: var(--muted); text-decoration: line-through; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 5px 10px; font-size: 13px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.active { color: #fff; font-weight: 600; }
.seg button.active.offen { background: #9ca3af; }
.seg button.active.in_arbeit { background: var(--s-in_arbeit); }
.seg button.active.blockiert { background: var(--s-blockiert); }
.seg button.active.erledigt { background: var(--s-erledigt); }
.steps .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.steps .tools select, .steps .tools input { width: auto; padding: 4px 8px; font-size: 13px; }
.steps .sub { margin: 10px 0 2px 36px; padding: 10px 12px; background: #f8fafc; border-radius: 8px; }
.count { font-size: 12px; color: var(--muted); }
.count.has { color: var(--accent); font-weight: 600; }

.comments { list-style: none; margin: 0 0 10px; padding: 0; }
.comments li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comments li:last-child { border-bottom: none; }
.comments .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comments .who b { color: var(--text); }
.comments .body { white-space: pre-wrap; word-break: break-word; }
.comments .body a { word-break: break-all; }
.attach { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach a { display: inline-flex; align-items: center; gap: 6px; background: #eef1f5; padding: 4px 10px; border-radius: 999px; font-size: 13px; color: var(--text); max-width: 100%; }
.attach a .x { color: var(--muted); }
.attach a .x:hover { color: #b91c1c; }
.addform { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.addform textarea { flex: 1; min-width: 220px; min-height: 44px; }
.addform input[type=file] { width: auto; }
.hint { font-size: 12px; color: var(--muted); }

.activity { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.activity li:last-child { border-bottom: none; }
.activity time { color: var(--muted); white-space: nowrap; min-width: 120px; }

.notif { position: absolute; right: 16px; top: 58px; width: 360px; max-width: calc(100vw - 32px); max-height: 70vh; overflow: auto; z-index: 40; }
.notif ul { list-style: none; margin: 0; padding: 0; }
.notif li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.notif li.unread { font-weight: 600; }
.notif li time { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }
.toast.err { background: #b91c1c; }

@media (max-width: 700px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .page { padding: 12px; }
  table.matrix thead th { top: 0; }
  table.matrix .title { max-width: 150px; font-size: 13px; }
  table.matrix .num { width: 36px; font-size: 12px; padding-right: 2px; }
  table.matrix th.step, table.matrix td.step { width: 40px; min-width: 40px; padding: 4px 3px; font-size: 10px; }
  .cell { width: 22px; height: 22px; border-radius: 6px; }
  table.matrix tr.hold td.title a::after { content: "⏸"; background: none; padding: 0; margin-left: 4px; }
  .section header { flex-wrap: wrap; gap: 4px 10px; }
  .steps .name { min-width: 0; }
}
