:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #eef0f3;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --text: #1d2330;
  --text-soft: #5c6575;
  --text-faint: #8b93a1;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --danger: #c2362f;
  --radius: 6px;
  --side: 264px;
  --row: 36px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.btn { border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--radius); padding: 6px 12px; line-height: 20px; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4fd0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.input, select.input, textarea.input { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 10px; background: var(--bg); width: 100%; }
.input:focus, .cell-edit:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: 12px; }
.error { color: var(--danger); margin: 8px 0; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--bg-soft); padding: 24px; }
.login form { width: 100%; max-width: 360px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; height: 100%; }
.side { border-right: 1px solid var(--line); background: var(--bg-soft); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 14px 14px 10px; display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; flex: 1; display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand img { width: 22px; height: 22px; }
.side-search { padding: 0 12px 10px; }
.side-nav { overflow: auto; flex: 1; padding: 0 6px 12px; }
.ws { margin-top: 6px; }
.ws > summary, .folder > summary { list-style: none; cursor: pointer; padding: 5px 8px; border-radius: var(--radius); color: var(--text-soft); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; display: flex; gap: 6px; align-items: center; }
.folder > summary { text-transform: none; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--text); }
.ws > summary::-webkit-details-marker, .folder > summary::-webkit-details-marker { display: none; }
.ws > summary::before, .folder > summary::before { content: "›"; display: inline-block; width: 10px; transition: transform .12s; color: var(--text-faint); }
.ws[open] > summary::before, .folder[open] > summary::before { transform: rotate(90deg); }
.ws > summary:hover, .folder > summary:hover { background: var(--bg-hover); }
.folder { margin-left: 8px; }
.nav-board { display: block; padding: 5px 8px 5px 24px; border-radius: var(--radius); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-board:hover { background: var(--bg-hover); text-decoration: none; }
.nav-board.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 6px; align-items: center; }
.side-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar { display: none; }
.menu-btn { display: none; }

/* ---------- Board ---------- */
.board-head { padding: 16px 24px 0; border-bottom: 1px solid var(--line); }
.board-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.board-title h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; flex: 1; min-width: 200px; }
.board-desc { margin: 4px 0 0; color: var(--text-soft); max-width: 80ch; }
.tabs { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--text-soft); white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.toolbar { display: flex; gap: 8px; padding: 10px 24px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.toolbar .input { width: 220px; }
.board-body { flex: 1; overflow: auto; padding: 8px 24px 80px; -webkit-overflow-scrolling: touch; }
.notice { background: #fff8e6; border: 1px solid #f1dca4; color: #6b5310; padding: 8px 12px; border-radius: var(--radius); margin: 8px 0; font-size: 13px; }

/* Tabelle */
.group { margin-top: 20px; }
.group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; position: sticky; left: 0; }
.group-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.group-head .count { color: var(--text-faint); font-size: 12px; }
.group-toggle { border: 0; background: none; padding: 2px 4px; color: var(--text-faint); }
table.grid { border-collapse: separate; border-spacing: 0; min-width: 100%; table-layout: fixed; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); height: var(--row); padding: 0; font-weight: normal; text-align: left; background: var(--bg); }
.grid th { font-size: 12px; color: var(--text-soft); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--line); }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; z-index: 1; border-left: 4px solid var(--gc, #579bfc); }
.grid th:first-child { z-index: 2; }
.grid tr:hover td { background: #fafbfc; }
.cell { padding: 0 8px; height: var(--row); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: default; }
.cell.editable { cursor: pointer; }
.cell > .t { overflow: hidden; text-overflow: ellipsis; }
.cell-name { justify-content: space-between; }
.cell-name .open { visibility: hidden; font-size: 12px; color: var(--text-soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; background: var(--bg); }
tr:hover .cell-name .open { visibility: visible; }
.cell-name .meta { color: var(--text-faint); font-size: 12px; display: flex; gap: 6px; }
.cell-edit { width: 100%; height: var(--row); border: 0; padding: 0 8px; background: var(--bg); }
.chip { display: block; width: 100%; text-align: center; color: #fff; padding: 0 6px; height: calc(var(--row) - 1px); line-height: calc(var(--row) - 1px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.status-cell { padding: 0; }
.tag { display: inline-block; background: var(--bg-hover); border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-right: 4px; }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #64748b; color: #fff; font-size: 10px; font-weight: 600; flex: none; }
.avatars { display: flex; gap: 2px; }
.add-row td { border-right: 0; }
.add-row input { border: 0; width: 100%; height: var(--row); padding: 0 8px; background: transparent; }
.add-row input::placeholder { color: var(--text-faint); }
.add-row input:focus { outline: none; background: var(--bg-soft); }

/* Popover */
.pop { position: fixed; z-index: 50; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(20, 30, 50, .14); padding: 6px; min-width: 200px; max-width: 320px; max-height: 360px; overflow: auto; }
.pop .opt { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: 4px; text-align: left; }
.pop .opt:hover, .pop .opt.sel { background: var(--bg-hover); }
.pop .swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.pop .input { margin-bottom: 6px; }

/* Kanban */
.kanban { display: flex; gap: 12px; align-items: flex-start; padding-top: 12px; min-height: 100%; }
.lane { width: 280px; flex: none; background: var(--bg-soft); border-radius: 8px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.lane-head { padding: 10px 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; border-top: 4px solid var(--lc); border-radius: 8px 8px 0 0; }
.lane-head .count { color: var(--text-faint); font-weight: normal; }
.lane-body { padding: 0 8px 8px; overflow: auto; flex: 1; min-height: 40px; }
.lane.drop .lane-body { background: var(--accent-soft); border-radius: 0 0 8px 8px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.card:hover { border-color: var(--line-strong); }
.card .title { font-weight: 500; margin-bottom: 4px; }
.card .row { font-size: 12px; color: var(--text-soft); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Kalender */
.cal-head { display: flex; align-items: center; gap: 8px; padding: 12px 0; }
.cal-head h2 { margin: 0; font-size: 16px; min-width: 160px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { font-size: 12px; color: var(--text-soft); padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.cal .day { min-height: 110px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; overflow: hidden; }
.cal .day.out { background: #fbfbfc; color: var(--text-faint); }
.cal .day.today .num { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; }
.cal .num { font-size: 12px; display: inline-block; margin-bottom: 2px; }
.cal .ev { display: block; width: 100%; font-size: 12px; text-align: left; border: 0; border-left: 3px solid var(--ec, var(--accent)); background: var(--bg-soft); padding: 2px 6px; margin-bottom: 2px; border-radius: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal .more { font-size: 11px; color: var(--text-soft); }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--bg); z-index: 31; display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(15, 23, 42, .12); }
.drawer-head { padding: 14px 20px 0; border-bottom: 1px solid var(--line); }
.drawer-head .crumbs { font-size: 12px; color: var(--text-soft); display: flex; gap: 6px; align-items: center; }
.drawer-head .crumbs .sp { flex: 1; }
.drawer-title { font-size: 20px; font-weight: 650; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; margin: 6px -6px 0; width: calc(100% + 12px); }
.drawer-title:hover { border-color: var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 16px 20px 60px; }
.composer { border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px; margin-bottom: 16px; }
.composer textarea { border: 0; width: 100%; resize: vertical; min-height: 64px; outline: none; }
.composer .actions { display: flex; justify-content: flex-end; gap: 6px; }
.update { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.update .by { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.update .by b { font-weight: 600; }
.update .body { overflow-wrap: anywhere; }
.update .body p { margin: 0 0 6px; }
.replies { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.reply { padding: 6px 0 6px 12px; border-left: 2px solid var(--line); margin-bottom: 6px; }
.props { display: grid; grid-template-columns: 180px 1fr; border-top: 1px solid var(--line); }
.props > div { border-bottom: 1px solid var(--line); min-height: var(--row); display: flex; align-items: center; }
.props .k { color: var(--text-soft); font-size: 13px; padding: 0 8px 0 0; }
.props .v { min-width: 0; }
.props .v .cell { width: 100%; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.files .ext { width: 40px; height: 40px; border-radius: 6px; background: var(--bg-soft); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; flex: none; }
.files .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dropzone { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 16px; text-align: center; color: var(--text-soft); margin-bottom: 12px; }
.dropzone.over { background: var(--accent-soft); border-color: var(--accent); }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 8px; }
.log .when { color: var(--text-faint); white-space: nowrap; width: 120px; flex: none; }
.log .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sub-list .grid { margin-top: 8px; }

/* Modal */
.modal { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 16px; }
.modal .box { background: var(--bg); border-radius: 10px; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 24px; position: relative; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal .close { position: absolute; right: 12px; top: 12px; }
.rule { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule .desc { flex: 1; min-width: 0; }
.rule-form { background: var(--bg-soft); border-radius: 8px; padding: 14px; margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.rule-form .full { grid-column: 1 / -1; }
.switch { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .12s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 16px; }

/* Seiten */
.page { padding: 24px; max-width: 1000px; }
.page h1 { font-size: 22px; margin: 0 0 16px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 12px; color: var(--text-soft); font-weight: 500; }
.result { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.result:hover { background: var(--bg-soft); text-decoration: none; }
.result .board { font-size: 12px; color: var(--text-soft); }
.empty { color: var(--text-soft); padding: 40px 0; text-align: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2330; color: #fff; padding: 8px 16px; border-radius: 6px; z-index: 60; font-size: 13px; max-width: calc(100% - 32px); }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 35; transform: translateX(-100%); transition: transform .18s; }
  .shell.nav-open .side { transform: none; box-shadow: 8px 0 32px rgba(15, 23, 42, .18); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 34; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar .brand { font-size: 15px; }
  .menu-btn { display: inline-block; }
  .board-head { padding: 12px 14px 0; }
  .board-title h1 { font-size: 19px; }
  .toolbar { padding: 8px 14px; }
  .toolbar .input { width: 100%; flex: 1 1 100%; order: 9; }
  .board-body { padding: 4px 12px 80px; }
  .grid th:first-child, .grid td:first-child { width: 190px !important; }
  .lane { width: 82vw; }
  .cal .day { min-height: 72px; }
  .cal .ev { font-size: 11px; padding: 1px 3px; }
  .props { grid-template-columns: 120px 1fr; }
  .rule-form { grid-template-columns: 1fr; }
  .drawer-body { padding: 12px 14px 60px; }
  .drawer-head { padding: 12px 14px 0; padding-top: max(12px, env(safe-area-inset-top)); }
  .log .when { width: 88px; }
  .page { padding: 16px; }
}
