:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1b1f27; --muted: #6b7280; --line: #e3e6ec;
  --accent: #2f5bea; --accent-soft: #e8eefd; --bad: #c62828; --bad-soft: #fdecec;
  --warn: #9a6200; --warn-soft: #fff4dc; --ok: #1e7d43; --lock: #6d4bc4;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --ink: #e8eaef; --muted: #9aa1ad; --line: #2b313c;
    --accent: #7b9bff; --accent-soft: #1f2a4a; --bad: #ff7b7b; --bad-soft: #3a1f22;
    --warn: #f0b44c; --warn-soft: #3a2f1a; --ok: #5fd08a; --lock: #b39cff;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.clickable { cursor: pointer; }
.count { background: var(--line); color: var(--muted); border-radius: 9px; padding: 0 7px; font-size: 11px; margin-left: 4px; letter-spacing: 0; }

/* поля и кнопки */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button, .btn { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; display: inline-block; color: var(--ink); }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--ink); }
button.small { padding: 4px 8px; font-size: 12px; }
.ghost-link { color: var(--muted); font-size: 13px; }
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; color: var(--ink); font-size: 14px; }
.row-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.row-check input { width: auto; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px 12px; }
.top-row { display: flex; align-items: center; gap: 18px; }
.brand { font-weight: 700; font-size: 16px; color: var(--ink); }
.brand.big { font-size: 22px; margin-bottom: 8px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 5px 10px; border-radius: 7px; white-space: nowrap; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a:hover { text-decoration: none; color: var(--ink); }
.top-right { display: flex; align-items: center; gap: 14px; }
.who { color: var(--ink); font-weight: 600; }
.bell { position: relative; color: var(--muted); display: flex; }
.bell.has { color: var(--accent); }
.bell-n { position: absolute; top: -6px; right: -9px; background: var(--bad); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; line-height: 15px; }
.bell-n:empty { display: none; }
.quick { display: flex; gap: 8px; margin-top: 10px; }
.quick input { font-size: 15px; padding: 9px 12px; }

main { padding: 18px 20px 40px; max-width: 1500px; margin: 0 auto; }
.flash { background: var(--warn-soft); color: var(--warn); padding: 8px 20px; border-bottom: 1px solid var(--line); }
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.pwd { font-size: 15px; padding: 2px 6px; background: var(--panel); border-radius: 5px; user-select: all; }

/* доска */
.board-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.board-head form.inline select { width: auto; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline .grow { flex: 1; min-width: 200px; }
.inline input, .inline select { width: auto; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { background: transparent; }
.col h3 { padding: 0 4px; }
.col-wait h3 { color: var(--warn); }
.list { min-height: 80px; display: flex; flex-direction: column; gap: 8px; padding: 2px; border-radius: var(--radius); }
.list.drop { background: var(--accent-soft); }
.hint { margin-top: 18px; }

.task { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 11px; box-shadow: var(--shadow); cursor: grab; }
.task.overdue, .task.remind { border-left: 3px solid var(--bad); }
.task.personal { border-style: dashed; }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-text { word-wrap: break-word; }
.check { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; padding: 0; margin-top: 1px; }
.check:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.tag.who { color: var(--ink); }
.tag.item { color: var(--accent); }
.tag.wait { color: var(--warn); }
.tag.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.tag.bad, .tag.due.bad, .tag.wait.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.tag.lock { color: var(--lock); }
.sortable-ghost { opacity: .4; }

/* сводка */
.summary { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.summary-head { display: flex; justify-content: space-between; align-items: center; }
.summary-grid { display: flex; gap: 28px; margin: 8px 0; }
.summary-grid b { font-size: 20px; }
.tight { margin: 4px 0; padding-left: 18px; }

/* модалка */
.overlay { position: fixed; inset: 0; background: rgba(10,14,22,.45); display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.card { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.card form { display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.title-input { font-size: 16px; font-weight: 600; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.history { margin-top: 12px; font-size: 12.5px; }
.history summary { cursor: pointer; color: var(--muted); }
.history ul { padding-left: 16px; margin: 6px 0; }
.history li { margin: 3px 0; }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable:hover td { background: var(--accent-soft); }
.tbl input, .tbl select { padding: 5px 7px; }
.w-n { width: 48px; } .w-s { width: 100px; } .w-m { width: 150px; }
.group { margin-bottom: 22px; }

/* 1:1 */
.weeknav { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.review { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.review section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.review .wide { grid-column: 1 / -1; background: transparent; border: none; padding: 0; }
.review .wide .task { margin-bottom: 8px; }
.line { padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.line:last-child { border-bottom: none; }
.done-line { color: var(--ok); }
.done-line .muted { color: var(--muted); }

/* сделано */
.week-head { display: flex; justify-content: space-between; align-items: center; }
.done-list { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.done-list li { padding: 7px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.done-list li:last-child { border-bottom: none; }

/* доработка */
.item-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.item-form { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.item-form .primary { align-self: flex-start; }
.item-layout aside .task { margin-bottom: 8px; }
.add-item { margin-bottom: 14px; }
.add-item summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }

.notes { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.notes li { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.notes li.unread { border-left: 3px solid var(--accent); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.narrow { max-width: 360px; }

/* вход */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 320px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }

/* мобильный */
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr 1fr; }
  .review { grid-template-columns: 1fr; }
  .item-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .top { padding: 8px 12px 10px; }
  main { padding: 14px 12px 40px; }
  .top-row { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; flex: 1 1 100%; }
  .top-right { margin-left: auto; }
  .board { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .quick button { display: none; }
  .tbl { display: block; overflow-x: auto; }
  .summary-grid { gap: 16px; }
}
