:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1c2126;
  --text-muted: #6b7280;
  --primary: #1f4e78;
  --primary-light: #eaf1f7;
  --danger: #c0392b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

#app { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 224px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { font-weight: 700; font-size: 15px; color: var(--primary); padding: 4px 8px 16px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 4px 6px 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-add-btn {
  width: 16px; height: 16px;
  border: none; background: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 13px; line-height: 1; font-weight: 700;
  padding: 0;
}
.sidebar-add-btn:hover { color: var(--primary); }
.sidebar-projects { display: flex; flex-direction: column; gap: 2px; }
.sidebar-project-link {
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.sidebar-project-link span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-project-link:hover, .sidebar-project-link.active { background: var(--primary-light); color: var(--primary); }
.sidebar-project-key { font-size: 10px; font-weight: 700; color: var(--text-muted); flex: none; }
.sidebar-projects-empty { color: var(--text-muted); font-size: 12px; padding: 4px 10px; }
.sidebar-spacer { flex: 1; }
.sidebar-footer { padding: 10px 8px 0; border-top: 1px solid var(--border); }
.current-user { color: var(--text-muted); font-size: 12px; }

.app-body { flex: 1; min-width: 0; }
#main { padding: 20px 24px 60px; max-width: 1400px; }

/* ---------- Board ---------- */
.board-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
select, input[type="text"], input[type="date"], textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
textarea { width: 100%; resize: vertical; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { opacity: 0.92; color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.spacer { flex: 1; }

.project-heading { display: flex; align-items: baseline; gap: 8px; margin-right: 4px; }
.project-name { font-weight: 700; font-size: 15px; }
.project-key { font-size: 11px; font-weight: 700; color: var(--text-muted); background: var(--bg); padding: 2px 6px; border-radius: 4px; }

.sprint-active-row { display: flex; align-items: center; gap: 8px; margin: 4px 2px 8px; font-size: 13px; }
.sprint-active-row input[type="checkbox"] { width: auto; }
.sprint-active-row label { font-weight: 400; color: var(--text); }

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
  overflow-x: auto;
}
.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  padding: 10px;
}
.column.dragover { outline: 2px dashed var(--primary); outline-offset: -2px; }
.column-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 6px 10px;
  color: var(--text-muted);
}
.column-count {
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: var(--shadow);
}
.card:active { cursor: grabbing; }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-key { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.02em; }
.card-team {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
}
.card-title { font-weight: 600; margin-bottom: 4px; line-height: 1.35; }
.card-meta { color: var(--text-muted); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; }
.priority-High { color: #b91c1c; font-weight: 600; }
.priority-Medium { color: #b45309; font-weight: 600; }
.priority-Low { color: #15803d; font-weight: 600; }
.priority-Unset { color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  padding: 22px 24px 24px;
  box-shadow: 0 20px 60px rgba(16,24,40,0.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; border: none; background: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.form-grid label.full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.comments { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--bg); }
.comment-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.comment-body { white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea { flex: 1; min-height: 40px; }

/* ---------- Docs ---------- */
.docs-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.docs-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  align-self: start;
}

.space-switcher { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.space-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  cursor: pointer;
}
.space-pill:hover { border-color: var(--primary); color: var(--primary); }
.space-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.space-pill-add { font-weight: 700; border-style: dashed; }

.space-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}

.doc-tree-empty { color: var(--text-muted); font-size: 12px; padding: 4px 8px; }
.doc-tree-row { display: flex; align-items: center; gap: 2px; border-radius: 6px; }
.doc-tree-row:hover { background: var(--primary-light); }
.doc-tree-row.active { background: var(--primary-light); }
.doc-tree-row.active .doc-link { color: var(--primary); font-weight: 600; }
.doc-link { flex: 1; display: block; padding: 6px 4px; border-radius: 6px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-toggle {
  width: 16px; height: 16px; flex: none;
  border: none; background: none; color: var(--text-muted);
  cursor: pointer; font-size: 10px; padding: 0; line-height: 1;
}
.tree-toggle-spacer { width: 16px; flex: none; display: inline-block; }
.tree-add-child {
  display: none; flex: none;
  width: 18px; height: 18px;
  border: none; background: var(--bg); border-radius: 4px;
  color: var(--text-muted); cursor: pointer; font-size: 12px; line-height: 1;
  align-items: center; justify-content: center;
  margin-right: 4px;
}
.doc-tree-row:hover .tree-add-child { display: inline-flex; }

.doc-breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.doc-breadcrumb a { color: var(--primary); }
.doc-breadcrumb a:hover { text-decoration: underline; }
.doc-breadcrumb .sep { margin: 0 6px; }

.docs-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-height: 400px;
}
.docs-content h1 { margin-top: 0; }
.docs-content img { max-width: 100%; }
.docs-content pre { background: var(--bg); padding: 10px 12px; border-radius: 6px; overflow-x: auto; }
.docs-content code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.doc-toolbar { display: flex; gap: 8px; margin-bottom: 16px; }
.doc-editor textarea { width: 100%; min-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.doc-linked { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.attachments { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }
.attachments-heading { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.attachments-empty { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }
.attachment-list { margin-bottom: 10px; }
.attachment-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--bg); font-size: 13px; }
.attachment-name { color: var(--primary); font-weight: 500; }
.attachment-name:hover { text-decoration: underline; }
.attachment-meta { color: var(--text-muted); font-size: 12px; flex: 1; }
.attachment-delete { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.attachment-delete:hover { color: var(--danger); }
.attachment-upload { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.attachment-upload input[type="file"] { font-size: 12px; }
.attachment-status { font-size: 12px; color: var(--text-muted); }

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