:root {
  --bg: #0f1117;
  --bg2: #161a23;
  --bg3: #1d2230;
  --bg4: #252b3b;
  --border: #2a3040;
  --text: #e6e9f0;
  --muted: #8a93a8;
  --accent: #5b8def;
  --accent-h: #6e9bf2;
  --danger: #e25c5c;
  --green: #4cc38a;
  --yellow: #e2b75c;
  --orange: #e2885c;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.flex1 { flex: 1; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
label > input, label > textarea, label > select { color: var(--text); font-size: 14px; }

/* ---------- buttons ---------- */
.btn-primary {
  background: var(--accent); color: #fff;
  border-radius: 8px; padding: 9px 18px; font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px;
  transition: background .15s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--bg4); }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(226,92,92,.4); border-radius: 8px; padding: 8px 14px;
}
.btn-danger:hover { background: rgba(226,92,92,.12); }
.btn-close { color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.btn-close:hover { background: var(--bg4); color: var(--text); }

/* ---------- auth ---------- */
.auth-view {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(91,141,239,.18), transparent), var(--bg);
}
.auth-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.auth-logo { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 22px; }
.auth-logo p { color: var(--muted); font-size: 12.5px; }
.auth-tabs {
  display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.auth-tabs button {
  flex: 1; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600;
}
.auth-tabs button.active { background: var(--bg3); color: var(--text); }
.auth-card .btn-primary { width: 100%; padding: 11px; margin-top: 4px; }
.auth-error {
  background: rgba(226,92,92,.12); border: 1px solid rgba(226,92,92,.35);
  color: #f0a0a0; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 250px; min-width: 250px; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; font-weight: 700; font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-label {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 8px; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.sidebar-label button {
  width: 22px; height: 22px; border-radius: 6px; background: var(--bg3);
  font-size: 15px; line-height: 1; color: var(--text);
}
.sidebar-label button:hover { background: var(--accent); }
.project-list { display: flex; flex-direction: column; gap: 2px; }
.project-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text);
}
.project-item:hover { background: var(--bg3); }
.project-item.active { background: var(--bg4); }
.project-item .dot { width: 10px; height: 10px; border-radius: 4px; flex-shrink: 0; }
.project-item .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .pcount { color: var(--muted); font-size: 12px; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--border);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info .muted { font-size: 12px; }
.sidebar-user button { color: var(--muted); font-size: 16px; padding: 6px; border-radius: 6px; }
.sidebar-user button:hover { color: var(--danger); background: var(--bg3); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; flex-shrink: 0;
  user-select: none;
}
.avatar.small { width: 24px; height: 24px; font-size: 10.5px; }

/* ---------- main / board ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--muted);
}
.empty-icon { font-size: 48px; }
.empty-state h2 { color: var(--text); }

.board-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.board-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.board-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.board-title .dot { width: 12px; height: 12px; border-radius: 4px; }
.board-title h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-actions { display: flex; gap: 8px; align-items: center; }
.board-actions input[type="search"] { width: 200px; padding: 8px 12px; }

.board {
  flex: 1; display: flex; gap: 14px;
  padding: 18px 20px; overflow-x: auto; overflow-y: hidden;
  align-items: flex-start;
}

.column {
  width: 290px; min-width: 290px; max-height: 100%;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
}
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
}
.column-head .col-name { font-weight: 700; font-size: 13.5px; flex: 1; }
.column-head .col-count {
  background: var(--bg4); color: var(--muted);
  border-radius: 10px; padding: 1px 8px; font-size: 11.5px;
}
.column-head .col-menu { color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.column-head .col-menu:hover { background: var(--bg4); color: var(--text); }
.column-body {
  flex: 1; overflow-y: auto; padding: 4px 10px 10px;
  display: flex; flex-direction: column; gap: 8px; min-height: 30px;
}
.column.drag-over .column-body { background: rgba(91,141,239,.07); border-radius: 8px; }
.column-add {
  padding: 8px 10px 12px;
}
.column-add button {
  width: 100%; text-align: left; color: var(--muted);
  padding: 8px 10px; border-radius: 8px;
}
.column-add button:hover { background: var(--bg3); color: var(--text); }
.column-add form { display: flex; gap: 6px; }
.column-add input { padding: 8px 10px; }

.add-column-btn {
  min-width: 270px; padding: 12px; border: 1px dashed var(--border);
  border-radius: var(--radius); color: var(--muted); text-align: center;
}
.add-column-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- card ---------- */
.card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: #3a425a; }
.card.dragging { opacity: .4; }
.card-title { font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.label-chip {
  font-size: 10.5px; padding: 1px 8px; border-radius: 8px;
  background: rgba(91,141,239,.18); color: #9db9f5;
}
.card-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 9px;
}
.prio { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.prio-low    { background: rgba(138,147,168,.18); color: var(--muted); }
.prio-normal { background: rgba(91,141,239,.18); color: #9db9f5; }
.prio-high   { background: rgba(226,136,92,.2); color: #f0b292; }
.prio-urgent { background: rgba(226,92,92,.2); color: #f0a0a0; }
.due { font-size: 11.5px; color: var(--muted); }
.due.overdue { color: var(--danger); font-weight: 600; }
.card-comments { font-size: 11.5px; color: var(--muted); }
.card-foot .avatar.small { margin-left: auto; }

.drop-placeholder {
  height: 8px; border-radius: 4px; background: var(--accent);
  opacity: .6; margin: -2px 0;
}

/* ---------- modals ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(5,8,15,.65);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px; z-index: 100; overflow-y: auto;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; width: 460px; max-width: 100%;
  box-shadow: var(--shadow);
}
.modal-wide { width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.modal-head h3 { font-size: 16px; }
.title-input {
  font-size: 17px; font-weight: 700; border: 1px solid transparent;
  background: transparent; padding: 6px 8px; margin-left: -8px;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: var(--accent); background: var(--bg); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; align-items: center; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
}
.color-swatch.active { border-color: #fff; }

.task-modal-grid { display: grid; grid-template-columns: 1fr 220px; gap: 22px; }
.task-side label { margin-bottom: 12px; }
.task-meta { font-size: 11.5px; line-height: 1.6; margin: 10px 0 14px; }
.task-side .btn-danger { width: 100%; }

.comments-block h4 { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.comments-list { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.comment-meta b { color: var(--text); font-weight: 600; }
.comment-text { font-size: 13px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; }
.comment-form .btn-primary { padding: 9px 14px; }

.member-add { display: flex; gap: 8px; margin-bottom: 16px; }
.members-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
}
.member-row:hover { background: var(--bg3); }
.member-row .m-info { flex: 1; min-width: 0; }
.member-row .m-info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .m-role { font-size: 11px; color: var(--muted); }
.member-row .m-remove { color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.member-row .m-remove:hover { color: var(--danger); background: var(--bg4); }

/* ---------- activity panel ---------- */
.activity-panel {
  width: 320px; min-width: 320px; background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; }
.activity-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.activity-item { font-size: 12.5px; line-height: 1.45; }
.activity-item b { font-weight: 600; }
.activity-item .a-time { color: var(--muted); font-size: 11px; margin-top: 1px; }
.activity-item .a-detail { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 20px; z-index: 200;
  box-shadow: var(--shadow); font-size: 13.5px;
}
.toast.error { border-color: rgba(226,92,92,.5); color: #f0a0a0; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ---------- mobile ---------- */
.burger {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-size: 16px;
}
@media (max-width: 760px) {
  .burger { display: block; }
  .sidebar { position: fixed; z-index: 55; height: 100%; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .board-head { padding-left: 64px; }
  .empty-state { padding-left: 48px; }
  .board-actions input[type="search"] { width: 120px; }
  .task-modal-grid { grid-template-columns: 1fr; }
  .activity-panel { position: fixed; right: 0; height: 100%; z-index: 50; }
}
