:root {
  --bg: #F4F4F1;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --column: #EAEAE5;
  --line: #E3E3DE;
  --line-strong: #DCDCD6;
  --ink: #1F2328;
  --ink-2: #4B4F55;
  --muted: #5F6368;
  --hover: #F0F0EC;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --danger: #B42318;
  --danger-bg: #FEE4E2;
  --radius: 10px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Каркас ---------- */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.sidebar {
  flex: 1 1 240px; max-width: 100%; background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 22px;
}
.main { flex: 999 1 560px; min-width: 0; padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 20px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-body { display: flex; flex-direction: column; gap: 22px; }
.btn.menu-btn { display: none; }
@media (max-width: 820px) {
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 16px; }
  .btn.menu-btn { display: inline-flex; }
  .sidebar:not(.open) .sidebar-body { display: none; }
  .main { padding: 20px 16px 32px; }
}
a.nav-item { color: inherit; text-decoration: none; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand-name { font-weight: 700; font-size: 17px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--hover); font-weight: 600; }
.nav-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-item .sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.nav-item .count { font-size: 12px; color: var(--muted); }
.nav-dashed { border: 1px dashed #C9C9C3; color: var(--muted); margin-top: 4px; }
.swatch-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ---------- Заголовки ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-head .crumbs { font-size: 13px; color: var(--muted); }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head .desc { color: var(--ink-2); }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-dot { width: 12px; height: 12px; border-radius: 3px; }
.curator-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.curator-line .label { color: var(--muted); }
.head-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- Кнопки и поля ---------- */
.btn {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #1D4ED8; }
.btn-danger { color: var(--danger); border-color: #F3C6C1; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-small { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { min-width: 36px; min-height: 36px; padding: 0; border: 0; background: transparent; border-radius: 8px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 12px; min-height: 44px; }
.search input { border: 0; outline: 0; background: transparent; width: 180px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
.field textarea { min-height: 96px; resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.title-input { font-size: 20px; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; width: 100%; background: transparent; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--line-strong); background: var(--surface); }

/* ---------- Сводка ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 700; }

/* ---------- Доска ---------- */
.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.column { background: var(--column); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; transition: box-shadow .15s; }
.column.drop-target { box-shadow: inset 0 0 0 2px var(--accent); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; }
.column-head h2 { font-size: 14px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.pill-count { font-size: 12px; color: var(--ink-2); background: var(--line-strong); border-radius: 10px; padding: 1px 8px; }
.empty-col { border: 1px dashed #C9C9C3; border-radius: var(--radius); padding: 18px; text-align: center; font-size: 13px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px; cursor: pointer;
}
.card:hover { border-color: #C9C9C3; }
.card.dragging { opacity: .5; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-key { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.4; word-break: break-word; }
.card-title-btn { all: unset; cursor: pointer; font-size: 14px; font-weight: 600; line-height: 1.4; word-break: break-word; }
.card-title-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meta-items { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.meta-item { display: inline-flex; align-items: center; gap: 4px; }
.meta-item.overdue { color: var(--danger); font-weight: 600; }

.prio { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.prio-high { color: #9A3412; background: #FFEDD5; }
.prio-mid { color: #1E40AF; background: #DBEAFE; }
.prio-low { color: #3F4448; background: #ECECE7; }

.avatar { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-lg { width: 28px; height: 28px; font-size: 12px; }
.avatar-empty { background: #ECECE7; color: var(--muted); }

.progress { flex: 1; height: 6px; background: #ECECE7; border-radius: 3px; overflow: hidden; }
.progress > div { height: 6px; background: var(--accent); }
.progress-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

.subs-toggle {
  min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 0 10px; text-align: left; width: 100%;
}
.subs-toggle .grow { flex: 1; }
.subs-toggle .hint { font-size: 12px; color: var(--muted); }
.sub-list { list-style: none; margin: 0; padding: 0 2px; display: flex; flex-direction: column; }
.sub-item label { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 13px; cursor: pointer; }
.sub-item input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.sub-item.done span { text-decoration: line-through; color: var(--muted); }

.quick-add { display: flex; flex-direction: column; gap: 8px; }
.quick-add textarea { width: 100%; min-height: 64px; resize: vertical; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.quick-add .row { display: flex; gap: 8px; }
.add-btn { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); text-align: left; padding: 0 8px; display: flex; align-items: center; gap: 8px; width: 100%; }
.add-btn:hover { background: rgba(0,0,0,.05); }

/* ---------- Все проекты ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.table-inner { min-width: 980px; }
.trow {
  display: grid; grid-template-columns: minmax(200px, 1.4fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(260px, 2fr) minmax(120px, .9fr) 112px;
  gap: 16px; padding: 16px 20px; border-bottom: 1px solid #EFEFEA; align-items: center;
}
.trow:last-child { border-bottom: 0; }
.thead { padding: 12px 20px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.cell-project { display: flex; align-items: flex-start; gap: 10px; }
.cell-project .dot { width: 12px; height: 12px; border-radius: 3px; margin-top: 4px; flex-shrink: 0; }
.cell-project .name { font-size: 15px; font-weight: 600; }
.cell-stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.small-muted { font-size: 12px; color: var(--muted); }
.cell-person { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.empty-state { background: var(--surface); border: 1px dashed #C9C9C3; border-radius: 12px; padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state p { margin: 0; color: var(--ink-2); max-width: 420px; }

/* ---------- Модальные окна ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 20, 19, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.modal-small { max-width: 480px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.section-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.edit-subs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.edit-sub { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.edit-sub input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }
.edit-sub input[type="text"] { flex: 1; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; background: transparent; min-width: 0; }
.edit-sub input[type="text"]:hover { border-color: var(--line); }
.edit-sub input[type="text"]:focus { border-color: var(--line-strong); background: var(--surface); }
.edit-sub.done input[type="text"] { text-decoration: line-through; color: var(--muted); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

.comments { display: flex; flex-direction: column; gap: 12px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.comment-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.comment-head strong { color: var(--ink); font-size: 13px; }
.comment-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 8px; border: 2px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }

.member-row { display: flex; align-items: center; gap: 10px; }
.member-row input { flex: 1; }

/* ---------- Прочее ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; }
.toast.show { opacity: 1; }
.loading { padding: 40px; color: var(--muted); }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 22px; }
.form-error { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }
