* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e4e7ef;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f6f7fb 60%);
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 360px; box-shadow: var(--shadow); text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; }
.login-sub { color: var(--muted); margin-bottom: 24px; }
.login-card input { margin-bottom: 12px; }
.login-error { color: var(--danger); margin-top: 10px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 8px 14px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; color: var(--muted); font-size: 16px;
  width: 26px; height: 26px; border-radius: 6px; line-height: 1;
}
.icon-btn:hover { background: #eef0f5; color: var(--text); }
.link-btn { border: none; background: none; color: var(--muted); text-decoration: underline; font-size: 12px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 270px; min-width: 270px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-header { padding: 20px 18px 12px; }
.logo { font-size: 17px; font-weight: 700; display: block; }
.logo-sub { color: var(--muted); font-size: 12px; }
.sidebar-section { padding: 12px 18px; border-top: 1px solid var(--border); }
.sidebar-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 10px;
}
.sidebar-footer {
  margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted);
}

.category-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px;
  cursor: pointer; margin-bottom: 2px; font-size: 13.5px;
}
.category-item:hover { background: #f3f4f6; }
.category-item.active { background: #eef2ff; font-weight: 600; }
.category-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-count { color: var(--muted); font-size: 12px; }

.progress-row { margin-bottom: 10px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.progress-bar { height: 6px; background: #eef0f5; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.view-tabs { display: flex; background: #eef0f5; border-radius: 8px; padding: 3px; }
.view-tab { border: none; background: transparent; padding: 6px 16px; border-radius: 6px; font-weight: 500; color: var(--muted); }
.view-tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-right input[type=search] { width: 180px; }
.topbar-right select { width: auto; }

.view-container { flex: 1; overflow: auto; padding: 20px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-todo { background: #eef0f5; color: #4b5563; }
.badge-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-blocked { background: #fee2e2; color: #b91c1c; }
.badge-done { background: #d1fae5; color: #047857; }
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-medium { background: #fef9c3; color: #a16207; }
.badge-low { background: #eef0f5; color: #6b7280; }
.milestone-flag { color: #d97706; }

/* ---------- List view ---------- */
.list-group { margin-bottom: 26px; }
.list-group-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-weight: 700; font-size: 15px;
}
.list-table { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row {
  display: grid; grid-template-columns: 34px 1fr 110px 90px 110px 110px 70px;
  gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #fafbff; }
.list-row.header-row { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; cursor: default; background: #fafbfc; }
.list-row.done .row-title { text-decoration: line-through; color: var(--muted); }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-check { width: 18px; height: 18px; cursor: pointer; }
.row-date { color: var(--muted); font-size: 12.5px; }
.overdue { color: var(--danger); font-weight: 600; }

/* ---------- Board view ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; min-height: 100%; }
.board-col { width: 300px; min-width: 300px; background: #eef0f5; border-radius: var(--radius); padding: 10px; }
.board-col-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 700; font-size: 13.5px; }
.board-col-count { color: var(--muted); font-weight: 500; }
.board-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: grab; box-shadow: var(--shadow);
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: .5; }
.card-title { font-weight: 500; margin-bottom: 6px; line-height: 1.35; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-cat { font-size: 11px; padding: 2px 7px; border-radius: 999px; color: #fff; font-weight: 600; }
.card-date { font-size: 11.5px; color: var(--muted); }
.board-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }

/* ---------- Timeline view ---------- */
.timeline-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.timeline { min-width: 900px; position: relative; }
.timeline-header { display: flex; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fafbfc; z-index: 2; }
.timeline-label-col { width: 280px; min-width: 280px; padding: 8px 12px; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; border-right: 1px solid var(--border); }
.timeline-months { display: flex; flex: 1; }
.timeline-month { border-right: 1px solid var(--border); padding: 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); overflow: hidden; white-space: nowrap; }
.timeline-cat-row { display: flex; align-items: center; background: #f3f4f6; border-bottom: 1px solid var(--border); }
.timeline-cat-label { width: 280px; min-width: 280px; padding: 7px 12px; font-weight: 700; font-size: 13px; display: flex; gap: 7px; align-items: center; border-right: 1px solid var(--border); }
.timeline-row { display: flex; align-items: center; border-bottom: 1px solid #f0f1f5; }
.timeline-row:hover { background: #fafbff; }
.timeline-task-label {
  width: 280px; min-width: 280px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-right: 1px solid var(--border);
}
.timeline-row.done .timeline-task-label { color: var(--muted); text-decoration: line-through; }
.timeline-track { flex: 1; position: relative; height: 30px; }
.timeline-bar {
  position: absolute; top: 6px; height: 18px; border-radius: 5px; cursor: pointer;
  min-width: 6px; opacity: .9; display: flex; align-items: center;
}
.timeline-bar:hover { opacity: 1; box-shadow: 0 0 0 2px rgba(79,70,229,.3); }
.timeline-bar.milestone { border-radius: 3px; transform: rotate(0); }
.timeline-bar .bar-label { font-size: 10px; color: #fff; padding: 0 6px; overflow: hidden; white-space: nowrap; }
.timeline-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 1; }
.timeline-today-label { position: sticky; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto;
}
.modal { background: var(--panel); border-radius: 14px; width: 640px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-header h2 { font-size: 18px; }
.modal-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); flex: 1; }
.form-row { display: flex; gap: 12px; }
.checkbox-label { flex-direction: row !important; align-items: center; }
.checkbox-label input { width: auto; }
.modal-footer { display: flex; gap: 8px; padding: 0 22px 20px; align-items: center; }
.spacer { flex: 1; }

.comments-section { border-top: 1px solid var(--border); padding-top: 12px; }
.comments-section h3 { font-size: 13px; margin-bottom: 8px; }
.comment { padding: 8px 10px; background: #f6f7fb; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.comment-author { font-weight: 600; margin-right: 6px; }
.comment-time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .list-row { grid-template-columns: 30px 1fr 90px 80px; }
  .list-row > :nth-child(n+5) { display: none; }
}
