:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --sidebar: #1c1c1e;
  --sidebar-text: #d6d6d6;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e4e4e0;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --ok: #1f9d55;
  --warn: #d4380d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--warn); margin: 0; }

/* Buttons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.btn:hover { border-color: #c9c9c4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--warn); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px; color: inherit; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.link-btn { border: 0; background: none; padding: 4px 0; cursor: pointer; color: inherit; text-align: left; opacity: .8; }
.link-btn:hover { opacity: 1; text-decoration: underline; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }

/* Login */
.auth { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--panel); padding: 28px; border-radius: 14px; width: 100%; max-width: 360px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.auth-card label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: #111; color: #fff; display: grid; place-items: center; font-weight: 700; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.sidebar .brand { color: #fff; padding: 2px 6px 6px; }
.sidebar .brand-mark { background: #fff; color: #111; }
.search { background: #2c2c2e !important; border-color: #3a3a3c !important; color: #fff; }
.nav-item { display: flex; justify-content: space-between; gap: 8px; padding: 7px 8px; border-radius: 7px; color: var(--sidebar-text); text-decoration: none; }
.nav-item:hover { background: #2c2c2e; }
.nav-item.active { background: #3a3a3c; color: #fff; }
.nav-item .count { opacity: .55; font-size: 12px; }
.nav-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.project-list { display: grid; gap: 1px; }
#toggle-archive { padding: 4px 8px; font-size: 13px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 2px; padding: 10px 8px 0; border-top: 1px solid #333; font-size: 13px; }
.me-name { color: #fff; font-weight: 600; margin-bottom: 4px; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.topbar h1.editable { cursor: text; }
.view-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.view { flex: 1; overflow: auto; padding: 18px 22px; }
.mobile-only { display: none; }

/* Board */
.board { display: flex; gap: 14px; align-items: flex-start; height: 100%; }
.column { flex: 0 0 290px; background: #ececea; border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.column-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px 12px; font-weight: 600; }
.column-head .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.column-head .count { color: var(--muted); font-weight: 400; font-size: 12px; }
.column-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 40px; }
.column-body.drop-target { background: rgba(47,111,237,.07); border-radius: 8px; }
.add-column { flex: 0 0 240px; }
.card { background: var(--panel); border-radius: 9px; padding: 10px 11px; box-shadow: var(--shadow); cursor: pointer; display: grid; gap: 6px; border: 1px solid transparent; }
.card:hover { border-color: #d6d6d1; }
.card.dragging { opacity: .4; }
.card.done .card-title { color: var(--muted); text-decoration: line-through; }
.card-top { display: flex; gap: 8px; align-items: flex-start; }
.card-title { flex: 1; line-height: 1.35; word-break: break-word; }
.card-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.drop-line { height: 3px; background: var(--accent); border-radius: 2px; }
.add-card-btn { border: 0; background: none; color: var(--muted); text-align: left; padding: 6px 4px; cursor: pointer; border-radius: 6px; }
.add-card-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }

/* Check circle */
.check { width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%; border: 1.5px solid #b5b5b0; background: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; margin-top: 1px; }
.check:hover { border-color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }

.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; flex: 0 0 22px; }
.due { white-space: nowrap; }
.due.overdue { color: var(--warn); font-weight: 600; }
.due.today { color: var(--ok); font-weight: 600; }

/* Liste */
.list-group { margin-bottom: 22px; }
.list-group h3 { font-size: 14px; margin: 0 0 6px; display: flex; gap: 8px; align-items: baseline; }
.list-group h3 .count { color: var(--muted); font-weight: 400; font-size: 12px; }
.list-row { display: grid; grid-template-columns: 22px 1fr 160px 150px 90px; gap: 12px; align-items: center; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); cursor: pointer; }
.list-row:first-of-type { border-radius: 8px 8px 0 0; }
.list-row:last-child { border-radius: 0 0 8px 8px; border-bottom: 0; }
.list-row:hover { background: #fafaf8; }
.list-row.done .row-title { color: var(--muted); text-decoration: line-through; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-user { display: flex; gap: 6px; align-items: center; font-size: 13px; overflow: hidden; white-space: nowrap; }
.inline-add { display: flex; gap: 8px; padding: 8px 10px; background: var(--panel); border-radius: 0 0 8px 8px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Drawer */
.drawer { position: fixed; top: 0; right: 0; width: min(560px, 100vw); height: 100vh; background: var(--panel); box-shadow: -8px 0 30px rgba(0,0,0,.12); overflow-y: auto; z-index: 20; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.drawer-head .spacer { flex: 1; }
.drawer-body { padding: 16px 20px 40px; display: grid; gap: 18px; }
.crumbs { font-size: 12px; color: var(--muted); display: flex; gap: 4px; flex-wrap: wrap; }
.crumbs a { color: var(--accent); cursor: pointer; text-decoration: none; }
.title-input { font-size: 20px; font-weight: 650; border: 1px solid transparent !important; padding: 4px 6px !important; margin-left: -6px; }
.title-input:hover { border-color: var(--line) !important; }
.fields { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; align-items: center; }
.fields > span { color: var(--muted); font-size: 13px; }
.block h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.subtask { display: flex; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.subtask .t { flex: 1; }
.subtask.done .t { color: var(--muted); text-decoration: line-through; }
.attachment { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.attachment a { color: var(--accent); text-decoration: none; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 8px 0; }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.comment .body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; line-height: 1.45; }
.comment.system { color: var(--muted); font-size: 12px; grid-template-columns: 26px 1fr; padding: 3px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #f0f0ec; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

/* Modal & Toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 30; padding: 20px; }
.modal-box { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; display: grid; gap: 14px; }
.modal-box h2 { margin: 0; font-size: 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.form-row { display: grid; gap: 4px; }
.form-row > span { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.user-row .sub { color: var(--muted); font-size: 12px; }
.log { background: #111; color: #d7d7d7; font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 10px; border-radius: 8px; max-height: 260px; overflow-y: auto; white-space: pre-wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d1d1f; color: #fff; padding: 10px 16px; border-radius: 9px; z-index: 40; box-shadow: var(--shadow); }
.toast.err { background: var(--warn); }
.checkbox { display: flex; gap: 8px; align-items: center; }
.checkbox input { width: auto; }

/* Mobil */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 25; transform: translateX(-105%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; }
  .mobile-only { display: inline-block; }
  .view { padding: 12px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .list-row { grid-template-columns: 22px 1fr 90px; }
  .list-row .hide-sm { display: none; }
  .column { flex-basis: 82vw; }
  .fields { grid-template-columns: 90px 1fr; }
}
