:root {
  --bg: #f4f2ee;
  --panel: #fbfaf8;
  --card: #ffffff;
  --ink: #1d1d1b;
  --ink-2: #55534e;
  --muted: #8a877f;
  --line: #e3e0d9;
  --green: #2f6b5a;
  --amber: #e0a43a;
  --red: #c8553d;
  --blue: #3c6fb4;
  --violet: #7a5aa6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 28, 20, .06), 0 1px 1px rgba(30, 28, 20, .04);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small-text { font-size: 12.5px; margin: 4px 0 10px; }

/* ---------- buttons & inputs */
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #cfcbc2; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #33322e; }
button.ghost { background: transparent; }
button.small { padding: 5px 9px; font-size: 13px; }
button.danger { color: var(--red); }
select, input[type=search], input[type=date], input:not([type]), input[type=password], textarea {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 9px; min-width: 0;
}
select:focus, input:focus, textarea:focus, button:focus-visible { outline: 2px solid #9cc3b6; outline-offset: 0; }

/* ---------- header */
.top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; }
.bot-state { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.bot-state.on { background: #3aa76d; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.filters input[type=search] { width: 190px; }
.actions { display: flex; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button { border: 0; border-radius: 0; padding: 7px 10px; background: transparent; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #fff; }
.toggle { display: inline-flex; flex-direction: row; font-size: 13px; gap: 6px; align-items: center; color: var(--ink-2); cursor: pointer; user-select: none; }

/* ---------- stats */
.stats { display: flex; gap: 10px; padding: 14px 20px 0; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 14px; min-width: 120px; cursor: default;
}
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.warn b { color: var(--red); }
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: #cfcbc2; }

/* ---------- board */
.board { display: flex; gap: 14px; padding: 14px 20px 30px; overflow-x: auto; flex: 1; align-items: flex-start; }
.col {
  flex: 0 0 300px; background: #ebe8e2; border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; max-height: calc(100vh - 190px);
}
.col.drop { outline: 2px dashed var(--green); outline-offset: -2px; background: #e4ece8; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; }
.col-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-head .count { color: var(--muted); font-weight: 500; }
.col-head .add { margin-left: auto; border: 0; background: transparent; color: var(--muted); padding: 2px 6px; font-size: 18px; line-height: 1; }
.col-head .add:hover { color: var(--ink); }
.col-body { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; padding-bottom: 4px; }
.col-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 14px 0; }

.card {
  background: var(--card); border-radius: 9px; padding: 10px 11px; box-shadow: var(--shadow);
  border: 1px solid transparent; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: #d8d4cb; }
.card.dragging { opacity: .45; }
.card.done .c-title { color: var(--muted); text-decoration: line-through; }
.card.prio-urgent { border-left: 3px solid var(--red); }
.card.prio-high { border-left: 3px solid var(--amber); }
.c-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.c-top .tg { margin-left: auto; opacity: .75; }
.proj-tag { background: #f0ede7; padding: 1px 7px; border-radius: 20px; color: var(--ink-2); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-title { line-height: 1.35; word-break: break-word; }
.c-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10.5px; font-weight: 650; color: #fff; flex: none;
}
.avatar.none { background: #d6d2c9; color: #6d6a63; }
.who { color: var(--ink-2); }
.pill { padding: 1px 7px; border-radius: 20px; background: #f0ede7; color: var(--ink-2); }
.pill.overdue { background: #f8e3dd; color: #a23c26; }
.pill.today { background: #fbefd6; color: #8a5a08; }
.pill.st-todo { background: #efeeea; }
.pill.st-doing { background: #e1eaf6; color: #2c568f; }
.pill.st-review { background: #ece4f5; color: #5d3f8a; }
.pill.st-done { background: #e0efe7; color: #22604a; }
.empty-state { color: var(--muted); padding: 40px; }

/* ---------- dialogs */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(620px, 94vw);
  box-shadow: 0 20px 60px rgba(20, 18, 10, .25); color: var(--ink); background: var(--panel);
}
dialog.wide { width: min(860px, 96vw); padding: 0 22px 22px; }
dialog::backdrop { background: rgba(30, 28, 22, .35); }
#taskForm { padding: 18px 22px 18px; }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; }
.dlg-head .x { margin-left: auto; border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 2px 6px; color: var(--muted); }
.title-input { width: 100%; border: 0; background: transparent; font-size: 19px; font-weight: 600; resize: none; padding: 6px 0; overflow: hidden; }
.title-input:focus { outline: 0; border-bottom: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
label.block textarea { width: 100%; resize: vertical; font-size: 14px; color: var(--ink); }
label select, label input { font-size: 14px; color: var(--ink); }
.activity { margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.activity summary { cursor: pointer; color: var(--muted); }
.activity ul { list-style: none; padding: 0; margin: 8px 0 0; max-height: 160px; overflow-y: auto; }
.activity li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.dlg-foot { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.spacer { flex: 1; }
h3 { margin: 20px 0 2px; font-size: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl input { width: 100%; padding: 5px 7px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inline-add input { flex: 1; min-width: 140px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 9px; opacity: 0;
  transition: .2s; pointer-events: none; z-index: 50; font-size: 13.5px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

/* ---------- login */
.login-body { display: grid; place-items: center; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(340px, 92vw); display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 18px; margin: 0 0 4px; }
.login input { font-size: 15px; }
.login button { margin-top: 6px; padding: 9px; }
.err { color: var(--red); min-height: 1em; margin: 0; font-size: 13px; }

@media (max-width: 760px) {
  .top { padding: 10px 12px; }
  .filters input[type=search] { width: 100%; }
  .board { padding: 12px; }
  .col { flex-basis: 84vw; }
  .stats { padding: 12px 12px 0; }
}
