/* ============ Планы — тёмная тема ============ */
:root {
  --bg: #0d0f16;
  --bg-soft: #12151f;
  --panel: #161a26;
  --panel-2: #1c2130;
  --panel-3: #232939;
  --border: #262d3f;
  --border-soft: #1e2434;
  --text: #eef1f8;
  --text-dim: #9aa3b8;
  --text-faint: #6b7488;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; }

/* ============ Кнопки, поля ============ */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, .35);
}
.btn-danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--panel-2); }
.btn-lg { width: 100%; padding: 13px; font-size: 16px; border-radius: 12px; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-dim);
  border-radius: 9px; font-size: 17px; cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 6px; letter-spacing: .02em;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-error {
  color: #fca5a5; font-size: 13.5px; margin: 2px 0 12px;
  background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3);
  padding: 9px 12px; border-radius: var(--radius-sm);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ Страницы входа ============ */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; position: relative; overflow: hidden;
}
.auth-blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; pointer-events: none;
}
.auth-blob-1 { width: 420px; height: 420px; background: #4338ca; top: -120px; right: -80px; }
.auth-blob-2 { width: 380px; height: 380px; background: #7c3aed; bottom: -140px; left: -100px; }
.auth-card {
  position: relative; width: 100%; max-width: 380px;
  background: rgba(22, 26, 38, .88);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 30px 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.auth-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 24px; letter-spacing: -.02em; }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 14px; margin: 6px 0 24px; }

/* ============ Каркас приложения ============ */
#app { display: flex; height: 100vh; height: 100dvh; }

#sidebar {
  width: 260px; flex: 0 0 260px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  gap: 6px;
  z-index: 40;
}
.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 16px; font-weight: 800; font-size: 18px; letter-spacing: -.02em;
}
.side-logo-icon { font-size: 22px; }

#side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14.5px; font-weight: 600;
  cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
.nav-item .nav-icon { width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
}

.side-section { margin-top: 14px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 6px; color: var(--text-faint);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
}
#side-boards { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.board-dot {
  width: 10px; height: 10px; border-radius: 4px; flex: 0 0 auto;
}

#side-user {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px; margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
}
.side-user-info { flex: 1; min-width: 0; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 10px; border: none; background: transparent; text-align: left; }
.side-user-info:hover { background: var(--panel); }
.side-user-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 11.5px; color: var(--text-faint); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex: 0 0 auto;
  text-transform: uppercase;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10.5px; }

/* ============ Main / topbar ============ */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 58px;
  flex-wrap: wrap;
}
#burger { display: none; }
#topbar-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; min-width: 0; }
#topbar-title .board-dot { width: 12px; height: 12px; }
#topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#topbar-actions select, #topbar-actions input[type="search"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13.5px; outline: none;
}
#topbar-actions input[type="search"] { width: 150px; }
#topbar-actions select:focus, #topbar-actions input:focus { border-color: var(--accent); }

#view { flex: 1; min-height: 0; overflow: auto; padding: 20px; }

/* ============ Обзор ============ */
.overview-greet { margin-bottom: 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.overview-date { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; text-transform: capitalize; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 26px;
}
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.stat-label { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.stat-tile.tone-ok .stat-value { color: var(--ok); }
.stat-tile.tone-warn .stat-value { color: var(--warn); }
.stat-tile.tone-danger .stat-value { color: var(--danger); }
.stat-tile.tone-accent .stat-value { color: #a5b4fc; }

.section-title {
  font-size: 15px; font-weight: 800; margin: 24px 0 12px;
  display: flex; align-items: center; gap: 8px;
}

.boards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.board-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  overflow: hidden; position: relative;
  text-align: left; width: 100%;
}
.board-card:hover { transform: translateY(-2px); border-color: var(--border); box-shadow: var(--shadow); }
.board-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.board-card-title { font-weight: 800; font-size: 16px; margin: 4px 0 10px; color: var(--text); }
.board-card-meta { color: var(--text-dim); font-size: 12.5px; display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress { height: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; transition: width .3s; }

.board-card-new {
  border-style: dashed; border-color: var(--border);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-dim); font-weight: 700; font-size: 14.5px; min-height: 108px;
  background: transparent; cursor: pointer; border-radius: var(--radius); border-width: 1px;
}
.board-card-new:hover { color: var(--text); border-color: var(--accent); }

.activity-list { display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.activity-text { flex: 1; min-width: 0; color: var(--text-dim); }
.activity-text b { color: var(--text); font-weight: 700; }
.activity-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }

.empty-hint {
  color: var(--text-faint); font-size: 14px; padding: 30px 10px; text-align: center;
}

/* ============ Канбан ============ */
#view.view-board { padding: 14px 14px 8px; overflow: hidden; display: flex; }
.kanban {
  display: flex; gap: 14px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  flex: 1; min-height: 0; height: 100%;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
}
.kanban-col {
  width: 292px; flex: 0 0 292px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  max-height: 100%;
  scroll-snap-align: start;
}
.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 8px;
}
.col-title { font-weight: 800; font-size: 14.5px; }
.col-title .done-mark { color: var(--ok); margin-left: 4px; }
.col-count {
  background: var(--panel-3); color: var(--text-dim);
  font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px;
}
.col-head .icon-btn { margin-left: auto; width: 28px; height: 28px; font-size: 15px; }
.col-tasks {
  flex: 1; min-height: 40px; overflow-y: auto;
  padding: 4px 10px; display: flex; flex-direction: column; gap: 8px;
}
.col-add {
  margin: 8px 10px 10px;
  border: none; background: transparent; color: var(--text-faint);
  font-size: 13.5px; font-weight: 700; text-align: left;
  padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer;
}
.col-add:hover { background: var(--panel-2); color: var(--text); }

.task-card {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color .12s, filter .12s;
  touch-action: pan-x pan-y;
}
.task-card:hover { filter: brightness(1.12); }
.task-title { font-size: 14px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.task-title.done { text-decoration: line-through; color: var(--text-dim); }
.task-meta { display: flex; align-items: center; gap: 8px; row-gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.task-meta:empty { display: none; }
.due-chip {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  background: var(--panel-3); padding: 2px 8px; border-radius: 99px;
}
.due-chip.overdue { color: #fca5a5; background: rgba(239, 68, 68, .14); }
.task-meta .avatar-sm { margin-left: auto; }
.desc-mark { color: var(--text-faint); font-size: 12px; }

.task-row { display: flex; gap: 9px; align-items: flex-start; }
.task-main { flex: 1; min-width: 0; }
.task-check {
  width: 19px; height: 19px; border-radius: 50%;
  border: 2px solid var(--text-faint); background: transparent;
  color: #fff; font-size: 11px; line-height: 1; padding: 0;
  cursor: pointer; flex: 0 0 auto; margin-top: 1px;
  transition: border-color .12s, background .12s, transform .1s;
}
.task-check:hover { border-color: var(--ok); transform: scale(1.1); }
.task-check.checked { background: var(--ok); border-color: var(--ok); }

.tag-chip {
  font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}

.cl-chip {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  background: var(--panel-3); padding: 2px 8px; border-radius: 99px;
}
.cl-chip.complete { color: #6ee7b7; background: rgba(16, 185, 129, .14); }

.quick-add { margin: 4px 10px 6px; }
.quick-add textarea {
  width: 100%; resize: none;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 14px; line-height: 1.4;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.quick-add-hint { color: var(--text-faint); font-size: 11px; padding: 5px 2px 0; }

.cl-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.cl-list:empty { margin-bottom: 0; }
.cl-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 7px 6px 7px 11px;
}
.cl-item input[type="checkbox"] {
  width: 17px; height: 17px; accent-color: var(--ok); flex: 0 0 auto; cursor: pointer;
}
.cl-item span { flex: 1; font-size: 14px; word-break: break-word; }
.cl-item.done span { text-decoration: line-through; color: var(--text-dim); }
.cl-item .icon-btn { width: 26px; height: 26px; font-size: 12px; }

.task-card.dragging { opacity: .35; }
.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none;
  width: 268px; transform: rotate(3deg);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
  opacity: .95;
}
.drop-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, .08);
}
.kanban-col.drop-target { border-color: var(--accent); }

.kanban-add-col {
  flex: 0 0 260px; width: 260px;
  border: 1px dashed var(--border);
  background: transparent; color: var(--text-faint);
  border-radius: var(--radius); padding: 14px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.kanban-add-col:hover { color: var(--text); border-color: var(--accent); }

/* ============ Мои задачи ============ */
.my-list { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.my-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; text-align: left; width: 100%; color: var(--text);
}
.my-item:hover { border-color: var(--border); filter: brightness(1.08); }
.my-item-main { flex: 1; min-width: 0; }
.my-item-title { font-size: 14.5px; font-weight: 700; }
.my-item-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.prio-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

/* ============ Команда ============ */
.users-list { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px;
}
.user-row.inactive { opacity: .5; }
.user-row-main { flex: 1; min-width: 0; }
.user-row-name { font-weight: 700; font-size: 14.5px; }
.user-row-sub { font-size: 12.5px; color: var(--text-dim); }
.role-badge {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 99px;
  background: var(--panel-3); color: var(--text-dim);
}
.role-badge.admin { background: rgba(99, 102, 241, .18); color: #a5b4fc; }

/* ============ Модалки ============ */
#modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 7, 12, .7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadein .15s ease;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 480px;
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: pop .18s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 8px;
}
.modal-head h2 { font-size: 17px; letter-spacing: -.01em; flex: 1; }
.modal-body { padding: 10px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; padding: 12px 18px 16px;
  border-top: 1px solid var(--border-soft);
}
.modal-foot .spacer { flex: 1; }
.modal-meta { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.color-swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.color-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* ============ Тосты ============ */
#toast-root {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastin .2s ease;
}
.toast.error { border-color: rgba(239, 68, 68, .5); color: #fca5a5; }

@keyframes fadein { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ============ Скроллбары ============ */
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ Мобилка ============ */
@media (max-width: 860px) {
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    width: 280px; flex-basis: 280px;
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  #backdrop {
    position: fixed; inset: 0; background: rgba(5, 7, 12, .6);
    opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 35;
  }
  body.sidebar-open #backdrop { opacity: 1; pointer-events: auto; }
  #burger { display: inline-flex; }
  #topbar { padding: 10px 12px; }
  #view { padding: 16px 14px; }
  #view.view-board { padding: 10px 10px 4px; }
  .kanban { scroll-snap-type: x mandatory; gap: 10px; }
  .kanban-col { width: 86vw; flex-basis: 86vw; max-width: 330px; }
  .kanban-add-col { flex-basis: 200px; width: 200px; }
  #topbar-actions input[type="search"] { width: 110px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none; border-radius: 18px 18px 0 0;
    max-height: 92dvh;
    animation: sheetup .22s cubic-bezier(.2, 1, .3, 1);
  }
  @keyframes sheetup { from { transform: translateY(40px); opacity: .6; } }
  .overview-greet { font-size: 20px; }
  .stat-value { font-size: 23px; }
}
