*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f3f5;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --border: #e2e5e9;
  --border-light: #edf0f2;
  --text: #1a1d21;
  --text-secondary: #5f6b7a;
  --text-muted: #8b95a5;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius: 8px;
  --radius-lg: 12px;
  --col-backlog: #6b7280;
  --col-todo: #3b82f6;
  --col-progress: #f59e0b;
  --col-done: #10b981;
  --prio-low: #6b7280;
  --prio-medium: #3b82f6;
  --prio-high: #f59e0b;
  --prio-urgent: #ef4444;
  --transition: .15s ease;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Header ── */
.header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 100;
}
.header-logo { font-weight: 700; font-size: 16px; color: var(--primary); white-space: nowrap; }
.header-search {
  flex: 1; max-width: 360px; margin: 0 auto;
  position: relative;
}
.header-search input {
  width: 100%; padding: 7px 12px 7px 34px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--bg); color: var(--text);
  transition: border-color var(--transition);
}
.header-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.header-search .icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.user-select {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 6px;
  cursor: pointer; border: 1px solid var(--border);
  font-size: 13px; background: var(--surface); transition: all var(--transition);
}
.user-select:hover { border-color: var(--primary); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 11px;
}

/* ── Board Tabs ── */
.board-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 0 20px; height: 44px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.board-tab {
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary); border-radius: 6px;
  transition: all var(--transition); white-space: nowrap;
}
.board-tab:hover { background: var(--bg); color: var(--text); }
.board-tab.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.board-tab-add {
  width: 30px; height: 30px; border-radius: 6px; border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: 16px;
  background: none; transition: all var(--transition);
}
.board-tab-add:hover { border-color: var(--primary); color: var(--primary); }

/* ── Kanban Board ── */
.board {
  display: flex; gap: 16px;
  padding: 20px;
  height: calc(100vh - 100px);
  overflow-x: auto; overflow-y: hidden;
}
.column {
  min-width: 300px; width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--radius-lg);
  max-height: 100%;
}
.column-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 10px;
  font-weight: 600; font-size: 13px;
  text-transform: uppercase; letter-spacing: .3px;
}
.column-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.column-count {
  margin-left: auto; background: var(--surface);
  padding: 1px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.column-body {
  flex: 1; overflow-y: auto; padding: 0 8px 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.column-body::-webkit-scrollbar { width: 4px; }
.column-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Task Card ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.card.dragging { opacity: .5; }
.card-title { font-size: 14px; font-weight: 500; margin-bottom: 6px; line-height: 1.4; }
.card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.card-priority {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
}
.card-assignee {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 9px;
}
.card-subtasks, .card-time, .card-comments {
  display: flex; align-items: center; gap: 3px;
}
.card-due {
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  background: var(--bg); color: var(--text-secondary);
}
.card-due.overdue { background: var(--danger-light); color: var(--danger); }
.add-card-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; margin: 4px 8px 8px;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px;
  border-radius: var(--radius); transition: all var(--transition);
}
.add-card-btn:hover { background: var(--surface); color: var(--text); }

/* ── Inline Add ── */
.inline-add {
  padding: 0 8px 8px;
}
.inline-add input {
  width: 100%; padding: 10px 12px;
  border: 2px solid var(--primary); border-radius: var(--radius);
  font-size: 14px; background: var(--surface); color: var(--text);
}
.inline-add input:focus { outline: none; }
.inline-add-actions {
  display: flex; gap: 6px; margin-top: 6px;
}

/* ── Detail Panel ── */
.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.detail-overlay.open { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed; top: 0; right: -560px; bottom: 0;
  width: 560px; max-width: 100vw;
  background: var(--surface); z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: right .25s ease;
}
.detail-panel.open { right: 0; }

.detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-close {
  width: 32px; height: 32px; border-radius: 6px;
  border: none; background: none; cursor: pointer;
  font-size: 18px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.detail-close:hover { background: var(--bg); color: var(--text); }
.detail-actions { margin-left: auto; display: flex; gap: 6px; }

.detail-body {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 24px;
}

.detail-title {
  font-size: 20px; font-weight: 600;
  border: none; background: none; width: 100%;
  padding: 4px 0; color: var(--text); line-height: 1.4;
}
.detail-title:focus { outline: none; border-bottom: 2px solid var(--primary); }

.detail-fields {
  display: grid; grid-template-columns: 100px 1fr; gap: 10px 16px;
  align-items: center; font-size: 13px;
}
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-fields select, .detail-fields input[type="date"] {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--surface); color: var(--text);
  max-width: 200px;
}
.detail-fields select:focus, .detail-fields input[type="date"]:focus {
  outline: none; border-color: var(--primary);
}

.detail-desc {
  width: 100%; min-height: 80px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; color: var(--text);
  resize: vertical; line-height: 1.6;
}
.detail-desc:focus { outline: none; border-color: var(--primary); }

/* ── Sections ── */
.section { border-top: 1px solid var(--border-light); padding-top: 16px; }
.section-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.section-head .toggle { transition: transform var(--transition); }
.section-head.collapsed .toggle { transform: rotate(-90deg); }
.section-count { font-weight: 400; color: var(--text-muted); }

/* ── Sub-tasks ── */
.subtask-list { display: flex; flex-direction: column; gap: 4px; }
.subtask-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  transition: background var(--transition);
}
.subtask-item:hover { background: var(--bg); }
.subtask-item input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer;
}
.subtask-item .subtask-text {
  flex: 1; font-size: 13px; border: none; background: none;
  color: var(--text); padding: 2px 0;
}
.subtask-item .subtask-text:focus { outline: none; border-bottom: 1px solid var(--primary); }
.subtask-item.done .subtask-text { text-decoration: line-through; color: var(--text-muted); }
.subtask-item .subtask-open {
  opacity: 0; padding: 2px 6px; border: none; background: none;
  cursor: pointer; font-size: 11px; color: var(--primary); border-radius: 4px;
}
.subtask-item:hover .subtask-open { opacity: 1; }
.subtask-item .subtask-open:hover { background: var(--primary-light); }
.subtask-item .subtask-delete {
  opacity: 0; padding: 2px 6px; border: none; background: none;
  cursor: pointer; font-size: 14px; color: var(--danger); border-radius: 4px;
}
.subtask-item:hover .subtask-delete { opacity: 1; }
.subtask-add {
  display: flex; gap: 6px; margin-top: 6px;
}
.subtask-add input {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; color: var(--text);
}
.subtask-add input:focus { outline: none; border-color: var(--primary); }

/* ── Time Tracking ── */
.time-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius); margin-bottom: 10px;
  font-size: 13px;
}
.time-total { font-weight: 600; font-size: 18px; color: var(--text); }
.timer-btn {
  margin-left: auto;
  padding: 6px 14px; border-radius: 6px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.timer-btn.start { background: var(--primary); color: #fff; }
.timer-btn.start:hover { background: var(--primary-hover); }
.timer-btn.stop { background: var(--danger); color: #fff; }
.timer-btn.stop:hover { background: #dc2626; }

.time-list { display: flex; flex-direction: column; gap: 4px; }
.time-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; font-size: 12px; color: var(--text-secondary);
  border-radius: 6px;
}
.time-entry:hover { background: var(--bg); }
.time-duration { font-weight: 600; min-width: 60px; color: var(--text); }
.time-note { flex: 1; color: var(--text-muted); }
.time-delete {
  opacity: 0; border: none; background: none; cursor: pointer;
  color: var(--danger); font-size: 14px;
}
.time-entry:hover .time-delete { opacity: 1; }

.time-add {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.time-add input {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--text);
}
.time-add input:focus { outline: none; border-color: var(--primary); }

/* ── Comments ── */
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment {
  display: flex; gap: 10px;
}
.comment-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 10px;
}
.comment-body { flex: 1; }
.comment-header {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
}
.comment-name { font-weight: 600; font-size: 13px; }
.comment-date { font-size: 11px; color: var(--text-muted); }
.comment-text { font-size: 13px; line-height: 1.5; color: var(--text-secondary); white-space: pre-wrap; }
.comment-actions { margin-top: 4px; display: flex; gap: 8px; }
.comment-action {
  border: none; background: none; cursor: pointer;
  font-size: 11px; color: var(--text-muted);
}
.comment-action:hover { color: var(--text); }

.comment-form {
  display: flex; gap: 8px; margin-top: 8px;
}
.comment-form textarea {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; font-family: inherit;
  color: var(--text); resize: none; min-height: 60px;
}
.comment-form textarea:focus { outline: none; border-color: var(--primary); }

/* ── Buttons ── */
.btn {
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: all var(--transition);
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger-light); }
.btn-danger:hover { background: var(--danger-light); }
.btn-ghost { border: none; }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted); border-radius: 6px;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── User Menu Dropdown ── */
.user-menu {
  position: absolute; top: 48px; right: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 150; min-width: 160px;
  display: none;
}
.user-menu.open { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  font-size: 13px; transition: background var(--transition);
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ── Board tab edit modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 300; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 24px;
  min-width: 360px; max-width: 90vw;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal input[type="text"] {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; color: var(--text);
}
.modal input[type="text"]:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Breadcrumb (for subtask navigation) ── */
.breadcrumb {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted); padding-bottom: 8px;
}
.breadcrumb a {
  color: var(--primary); text-decoration: none; cursor: pointer;
}
.breadcrumb a:hover { text-decoration: underline; }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted); font-size: 13px;
}

/* ── Login Screen ── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg);
}
.login-box {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 40px;
  text-align: center; min-width: 320px;
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.login-users { display: flex; gap: 16px; justify-content: center; }
.login-user {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 24px; border-radius: var(--radius-lg);
  border: 2px solid var(--border); cursor: pointer;
  transition: all var(--transition); background: none;
}
.login-user:hover { border-color: var(--primary); background: var(--primary-light); }
.login-user .avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
}
.login-user .name { font-weight: 600; font-size: 15px; }

/* ── Sortable ghost ── */
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow-md); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .board { padding: 12px; gap: 12px; }
  .column { min-width: 260px; width: 260px; }
  .detail-panel { width: 100vw; }
  .header-search { display: none; }
}
