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

:root {
  --bg: #f6f7fb;
  --sidebar-bg: #1c1f3b;
  --sidebar-text: #c5c9e0;
  --sidebar-active: #ffffff;
  --accent: #6161ff;
  --accent-hover: #4f4fe0;
  --accent-light: #ededff;
  --success: #00c875;
  --warning: #fdab3d;
  --danger: #e2445c;
  --text: #323338;
  --text-muted: #676879;
  --border: #e6e9ef;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
}

body {
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 22px;
  color: var(--accent);
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-nav {
  padding: 20px 12px 8px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(255,255,255,.35);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(97,97,255,.25); color: var(--sidebar-active); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-section {
  padding: 16px 12px 8px;
  flex: 1;
  overflow-y: auto;
}

.task-section { flex: 2; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-icon {
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.btn-icon:hover { background: var(--accent); }

.project-list, .task-list {
  list-style: none;
}

.project-item, .task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
  color: var(--sidebar-text);
}

.project-item:hover, .task-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.project-item.active, .task-item.active { background: rgba(97,97,255,.2); color: #fff; }

.project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.task-status-dot.todo { background: #c4c4c4; }
.task-status-dot.progress { background: var(--warning); }
.task-status-dot.done { background: var(--success); }

.task-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item-subcount {
  font-size: 11px;
  background: rgba(255,255,255,.12);
  padding: 1px 6px;
  border-radius: 10px;
}

/* ── Main ── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 36px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.main-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-stats {
  display: flex;
  gap: 24px;
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.empty-state p { max-width: 360px; line-height: 1.6; margin-bottom: 24px; }

/* ── Task detail ── */
.task-detail {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 760px;
}

.hidden { display: none !important; }

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-title-input {
  flex: 1;
  font-size: 24px;
  font-weight: 700;
  border: none;
  outline: none;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border-bottom: 2px solid transparent;
  padding: 4px 0;
  transition: border-color .15s;
}

.detail-title-input:focus { border-bottom-color: var(--accent); }

.status-select {
  padding: 6px 12px;
  border-radius: 20px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  background: #c4c4c4;
}

.status-select[data-status="todo"] { background: #c4c4c4; color: #333; }
.status-select[data-status="progress"] { background: var(--warning); }
.status-select[data-status="done"] { background: var(--success); }

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius);
}

.meta-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.meta-item input, .meta-item select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}

.meta-item input:focus, .meta-item select:focus { border-color: var(--accent); }

.detail-desc label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.detail-desc textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}

.detail-desc textarea:focus { border-color: var(--accent); }

/* ── Subtasks ── */
.subtasks-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.subtasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.subtasks-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.subtask-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-left: 6px;
}

.subtask-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  transition: background .15s;
}

.subtask-item:hover { background: var(--accent-light); }

.subtask-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.subtask-item.done .subtask-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.subtask-name {
  flex: 1;
  font-size: 14px;
}

.subtask-delete {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}

.subtask-item:hover .subtask-delete { opacity: 1; }
.subtask-delete:hover { color: var(--danger); }

.subtask-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.subtask-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.subtask-form input:focus { border-color: var(--accent); }

.detail-actions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Buttons ── */
.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 8px 16px;
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.btn-secondary:hover { background: #dcdcff; }

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  padding: 8px 16px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover { background: #fff0f2; }

.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ── Modal ── */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-width: 440px;
  width: 90%;
}

.modal::backdrop { background: rgba(0,0,0,.4); }

.modal-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-form h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
}

.modal-form input, .modal-form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.modal-form input:focus, .modal-form select:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .detail-meta { grid-template-columns: 1fr; }
}
