:root {
  --bg: #f7f8fb;
  --sidebar-bg: #ffffff;
  --column-bg: #eef0f5;
  --column-bg-hover: #e8ebf3;
  --card-bg: #ffffff;
  --border: #e6e8f0;
  --border-strong: #d7dbe6;
  --text: #1a1d29;
  --text-muted: #767c8f;
  --text-faint: #a3a8b8;
  --accent: #1f6b47;
  --accent-hover: #17573a;
  --accent-soft: #e7f3ec;
  --success: #12b76a;
  --success-soft: #e8faf1;
  --danger: #e6482e;
  --danger-soft: #fdeeec;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(21, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(21, 24, 40, 0.06), 0 1px 2px rgba(21, 24, 40, 0.08);
  --shadow-hover: 0 8px 20px rgba(21, 24, 40, 0.10), 0 2px 6px rgba(21, 24, 40, 0.08);
  --shadow-modal: 0 24px 48px -12px rgba(21, 24, 40, 0.35);
}

* { box-sizing: border-box; }

/* Author `display` rules on a class (.project-item, .board-tab, etc.) beat
   the UA's [hidden]{display:none} at equal specificity — the later rule in
   the sheet wins, and ours always comes later. Force it everywhere once,
   instead of re-discovering this per element (see modal-overlay[hidden],
   same bug, fixed 2026-09-08 morning). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}

::selection { background: var(--accent-soft); color: var(--accent-hover); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  padding: 2px 8px 24px;
}

.logo-sparrow {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  padding: 4px 10px 8px;
}

.project-list { display: flex; flex-direction: column; gap: 1px; }

.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.project-item > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item:hover { background: var(--bg); }
.project-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.project-item.add-item { color: var(--text-faint); font-weight: 500; margin-top: 6px; }
.project-item.add-item:hover { color: var(--accent); background: var(--accent-soft); }

.project-status {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.loading { color: var(--text-muted); font-size: 13px; padding: 8px 10px; }

.folder-block { margin-bottom: 2px; }

.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.folder-header:hover { background: var(--bg); }

.folder-toggle {
  flex-shrink: 0;
  width: 10px;
  color: var(--text-faint);
  font-size: 10px;
  transition: transform 0.12s ease;
}

.folder-header.collapsed .folder-toggle { transform: rotate(-90deg); }

.folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
}

.folder-projects {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  margin: 0 0 2px 20px;
}

.folder-projects:empty::after {
  content: 'Пусто — переместите проект значком 📁';
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 6px 10px;
}

.item-folder-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  opacity: 0;
  border-radius: 4px;
}

.project-item:hover .item-folder-btn { opacity: 0.6; }
.item-folder-btn:hover { opacity: 1 !important; background: var(--bg); }

.folder-picker-select {
  font-family: inherit;
  font-size: 12.5px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 4px;
  max-width: 120px;
}

/* ---- Main / boards ---- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.boards-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.current-project-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.board-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.board-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--bg);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.board-tab > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.board-tab:hover { background: var(--accent-soft); color: var(--accent-hover); }
.board-tab.active { background: var(--accent); color: #fff; font-weight: 600; }
.board-tab.add-item { color: var(--text-faint); border: 1px dashed var(--border-strong); background: transparent; }
.board-tab.add-item:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.board-view {
  flex: 1;
  overflow: auto;
  padding: 22px 28px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}
.empty-state h2 { color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 4px; }

/* ---- Kanban ---- */

.kanban {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 100%;
}

.kanban-column {
  background: var(--column-bg);
  border-radius: var(--radius);
  width: 284px;
  flex-shrink: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 12px;
  margin-bottom: 4px;
  position: relative;
}

.kanban-column-header::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 2.5px;
  border-radius: 999px;
  background: var(--col-accent, var(--accent));
  opacity: 0.55;
}

.kanban-column-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.kanban-column-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanban-column-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 2px;
  margin: -2px;
  border-radius: var(--radius-sm);
  transition: background-color 0.12s ease;
}

.task-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  cursor: grab;
  border: 1px solid transparent;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.task-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

.task-card.dragging {
  opacity: 0.4;
  transform: rotate(-1.5deg);
}

.kanban-cards.drag-over {
  background: rgba(91, 91, 240, 0.06);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.add-task-btn {
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.add-task-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.kanban-column.add-column {
  background: transparent;
  width: 224px;
  align-items: stretch;
  justify-content: flex-start;
  padding-top: 2px;
}

.add-column-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.add-column-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.inline-create-input {
  width: 100%;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.inline-create-input:focus { outline: none; }

.inline-rename-input { flex: 1; min-width: 0; padding: 4px 6px; }

.project-item.dragging,
.board-tab.dragging,
.kanban-column.dragging {
  opacity: 0.4;
}

.kanban-column-title { cursor: text; }
.kanban-column-header { cursor: grab; }

.task-card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 9px;
  padding-right: 20px;
  color: var(--text);
}

.task-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 9px;
}

.tag-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  letter-spacing: 0.01em;
}

.task-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
}

.due-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 7px;
  border-radius: 6px;
}

.due-date.overdue { color: var(--danger); background: var(--danger-soft); }

.avatars { display: flex; align-items: center; }

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card-bg);
  margin-left: -7px;
  box-shadow: var(--shadow-xs);
}
.avatar:first-child { margin-left: 0; }
.avatar.avatar-overflow { background: var(--text-faint); font-size: 9px; }

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 33, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: overlay-in 0.15s ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 26px;
  position: relative;
  box-shadow: var(--shadow-modal);
  animation: modal-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: var(--bg);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: background-color 0.12s ease, color 0.12s ease;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }

.modal h2 { margin: 0 24px 16px 0; font-size: 18px; }

.modal-field { margin-bottom: 18px; }
.modal-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.modal-field-value { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.modal-field-value.muted { color: var(--text-muted); font-style: italic; }
.modal-field-value a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.modal-field-value a:hover { color: var(--accent-hover); }

.picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.value-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
}

.picker-panel {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.picker-row:hover { background: var(--bg); }
.picker-row input { cursor: pointer; }

.modal-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-field-label-row .modal-field-label { margin-bottom: 0; }

.modal-edit-toggle {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.modal-edit-toggle:hover { color: var(--accent-hover); text-decoration: underline; }

.modal-title-input {
  width: 100%;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 24px 18px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  margin-left: -8px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.modal-title-input:hover { background: var(--bg); }
.modal-title-input:focus {
  border-color: var(--accent);
  background: #fff;
  outline: none;
}

.modal-field-input,
.modal-field-textarea {
  width: 100%;
  font-size: 13.5px;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  resize: vertical;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.modal-field-input:focus,
.modal-field-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.modal-save-status {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.05s ease;
}
.modal-save-btn:hover { background: var(--accent-hover); }
.modal-save-btn:active { transform: scale(0.97); }
.modal-save-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.login-modal { width: 360px; text-align: center; }
.login-modal h2 { margin: 0 0 8px; }
.login-modal p { color: var(--text-muted); font-size: 14px; margin: 0 0 18px; }

.login-link-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.12s ease;
}
.login-link-btn:hover { background: var(--accent-hover); }

.login-status { margin-top: 16px; font-size: 12px; color: var(--text-muted); }

/* ---- Delete controls ---- */

.item-delete-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.project-item:hover .item-delete-btn,
.board-tab:hover .item-delete-btn,
.kanban-column-header:hover .item-delete-btn {
  opacity: 1;
}

.item-delete-btn:hover { background: var(--danger-soft); color: var(--danger); }

.board-tab.active .item-delete-btn { color: rgba(255, 255, 255, 0.75); }
.board-tab.active .item-delete-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.task-card {
  position: relative;
}

.task-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: none;
  background: var(--card-bg);
  border-radius: 50%;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  box-shadow: var(--shadow-xs);
  transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.task-card:hover .task-delete-btn { opacity: 1; }
.task-delete-btn:hover { background: var(--danger-soft); color: var(--danger); }

.modal-delete-btn {
  margin-right: auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.modal-delete-btn:hover { background: var(--danger-soft); border-color: var(--danger-soft); }

/* ---- Mobile (<=768px) ---- */

.sidebar-toggle {
  display: none;
  border: none;
  background: var(--bg);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 82vw;
    max-width: 300px;
    z-index: 101;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-modal);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(21, 24, 40, 0.35);
    z-index: 100;
  }
  .sidebar-overlay[hidden] { display: none; }

  .boards-bar {
    padding: 12px 14px;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .current-project-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .board-tabs {
    flex-wrap: nowrap;
  }

  .board-tab {
    flex-shrink: 0;
  }

  .board-view {
    padding: 14px;
  }

  .kanban-column {
    width: 82vw;
    max-width: 320px;
  }

  /* No hover on touch — keep otherwise hover-only controls visible */
  .item-delete-btn,
  .item-folder-btn,
  .task-delete-btn {
    opacity: 1;
  }

  .modal {
    width: 100%;
    padding: 20px;
  }
}
