/* ============================================================
   ProjectBase Design System
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --color-bg:          #F9FAFB;
  --color-surface:     #FFFFFF;
  --color-border:      #E5E7EB;
  --color-border-dark: #D1D5DB;
  --color-text:        #111827;
  --color-text-muted:  #6B7280;
  --color-text-inv:    #FFFFFF;

  --color-accent:       #4F46E5;
  --color-accent-hover: #4338CA;
  --color-accent-light: #EEF2FF;
  --color-accent-border:#C7D2FE;

  --color-success:      #059669;
  --color-success-light:#ECFDF5;
  --color-warning:      #D97706;
  --color-warning-light:#FFFBEB;
  --color-danger:       #DC2626;
  --color-danger-light: #FEF2F2;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --header-h:  64px;
  --sidebar-w: 240px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; }
textarea { resize: vertical; }

/* --- App Layout (CSS Grid) --- */
.app-layout {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}
.app-header {
  grid-column: 1 / -1;
  grid-row: 1;
}
.app-sidebar {
  grid-row: 2;
  grid-column: 1;
  overflow-y: auto;
}
.app-content {
  grid-row: 2;
  grid-column: 2;
  padding: var(--space-8);
  overflow-y: auto;
  min-width: 0;
}

/* --- Header --- */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-accent);
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo:hover { text-decoration: none; }
.header-logo svg { width: 28px; height: 28px; }
.header-spacer { flex: 1; }
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Global task search */
.task-search {
  position: relative;
}
.task-search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  width: 200px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.task-search-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.task-search-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
}
.task-search-dropdown.open { display: block; }
.task-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.task-search-result:last-child { border-bottom: none; }
.task-search-result:hover { background: var(--color-bg); text-decoration: none; }
.task-search-result-body { flex: 1; min-width: 0; }
.task-search-result-title {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-search-result-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-search-empty {
  padding: 14px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.project-dropdown-divider { border-top: 1px solid var(--color-border); margin: var(--space-1) 0; }

/* User menu */
.user-menu {
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text);
}
.user-menu-btn:hover { background: var(--color-bg); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}
.user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.user-menu.open .user-dropdown-menu { display: block; }
.user-dropdown-menu a, .user-dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
}
.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover { background: var(--color-bg); text-decoration: none; }
.user-dropdown-menu .danger { color: var(--color-danger); }
.user-dropdown-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.user-dropdown-header .name { font-weight: 600; font-size: var(--text-sm); }
.user-dropdown-header .role { font-size: var(--text-xs); color: var(--color-text-muted); }

/* --- Sidebar --- */
.app-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-4) 0;
}
.sidebar-section {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-4);
}
.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-1);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.sidebar-nav a.active { background: var(--color-accent-light); color: var(--color-accent); font-weight: 500; }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-divider { border: none; border-top: 1px solid var(--color-border); margin: var(--space-3) var(--space-4); }

/* --- Mobile sidebar toggle --- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--color-text-muted);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 90;
}

/* --- Page header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: var(--text-lg); font-weight: 600; }
.status-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-secondary { background: white; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); border-color: var(--color-border-dark); }
.btn-danger    { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost     { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm        { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg        { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.btn:disabled  { opacity: .5; cursor: not-allowed; }
.btn svg       { width: 16px; height: 16px; }

/* --- Forms --- */
.form-group    { margin-bottom: var(--space-4); }
.form-label    { display: block; font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-2); color: var(--color-text); }
.form-label .required { color: var(--color-danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}
.form-input.error, .form-select.error, .form-textarea.error { border-color: var(--color-danger); }
.form-error    { color: var(--color-danger); font-size: var(--text-xs); margin-top: var(--space-1); }
.form-hint     { color: var(--color-text-muted); font-size: var(--text-xs); margin-top: var(--space-1); }
.form-textarea { min-height: 100px; }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-actions  { display: flex; gap: var(--space-3); align-items: center; margin-top: var(--space-6); }

/* --- Flash messages --- */
.flash-container { margin-bottom: var(--space-4); }
.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  animation: flash-in .2s ease;
}
@keyframes flash-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.flash-success { background: var(--color-success-light); color: #065F46; border-left: 3px solid var(--color-success); }
.flash-error   { background: var(--color-danger-light);  color: #991B1B; border-left: 3px solid var(--color-danger); }
.flash-warning { background: var(--color-warning-light); color: #92400E; border-left: 3px solid var(--color-warning); }
.flash-close   { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .5; flex-shrink: 0; line-height: 1; }
.flash-close:hover { opacity: 1; }

/* --- Badges / Tags --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}
.badge-success { background: var(--color-success-light); color: var(--color-success);        border: 1px solid #86efac; }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger);         border: 1px solid #fca5a5; }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning);        border: 1px solid #fde68a; }
.badge-primary { background: var(--color-accent-light);  color: var(--color-accent);         border: 1px solid var(--color-accent-border); }
.badge-info    { background: #dbeafe;                    color: #1d4ed8;                     border: 1px solid #93c5fd; }
.badge-purple  { background: #f3e8ff;                    color: #7c3aed;                     border: 1px solid #c4b5fd; }
.badge-teal    { background: #ccfbf1;                    color: #0f766e;                     border: 1px solid #5eead4; }
.badge-muted   { background: var(--color-bg);            color: var(--color-text-muted);     border: 1px solid var(--color-border); }
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-blocked {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  font-weight: 600;
}
.badge-ready {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #86efac;
  font-weight: 600;
}
.btn-block-toggle {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  color: #16a34a;
  line-height: 1.5;
  white-space: nowrap;
  transition: filter .15s;
}
.btn-block-toggle:hover { filter: brightness(.93); }

/* Count badge inside filter toggle buttons */
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.5;
  background: rgba(0,0,0,.12);
  color: inherit;
}
.btn-primary .filter-count { background: rgba(255,255,255,.3); }
.btn-block-toggle.is-blocked { background:#fee2e2; color:#dc2626; border-color:#fca5a5; }
.btn-block-toggle.is-closed  { background:#f3f4f6; color:#6b7280; border-color:#d1d5db; cursor:default; }
.btn-block-toggle.is-closed:hover { filter:none; }
.badge-closed { background:#f3f4f6; color:#6b7280; border:1px solid #d1d5db; font-weight:600; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--color-bg); }
.table tbody tr:last-child td { border-bottom: none; }

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--color-text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--space-4); opacity: .4; }
.empty-state h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-2); color: var(--color-text); }
.empty-state p { font-size: var(--text-sm); max-width: 320px; margin: 0 auto var(--space-6); }

/* --- Kanban Board --- */
.board-container {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: var(--space-8);
  min-height: calc(100vh - 180px);
}
.board-column {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
}
.board-column-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.board-column-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.board-column-count {
  margin-left: auto;
  background: var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  padding: 1px 7px;
  font-weight: 500;
}
.board-task-list {
  padding: var(--space-3);
  min-height: 80px;
  flex: 1;
}
.board-task-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.board-task-card:hover { box-shadow: var(--shadow-md); }
.board-task-card:active { cursor: grabbing; }
.board-task-id { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: 4px; }
.board-task-title { font-size: var(--text-sm); font-weight: 500; line-height: 1.4; }
.board-task-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.board-task-assignee {
  width: 20px; height: 20px;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.sortable-ghost  { opacity: .4; background: var(--color-accent-light); border: 1px dashed var(--color-accent-border); }
.sortable-drag   { box-shadow: var(--shadow-lg); transform: rotate(2deg); }
.board-col-adding { opacity: .5; }

/* --- Wiki --- */
.wiki-layout { display: grid; grid-template-columns: 280px 1fr; gap: var(--space-6); align-items: start; }
.wiki-tree {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  position: sticky;
  top: var(--space-4);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.wiki-tree-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-2);
  margin-bottom: var(--space-1);
}
.wiki-tree ul { padding-left: var(--space-4); }
.wiki-tree > ul { padding-left: var(--space-5); }
.wiki-tree li { position: relative; }
.wiki-tree a {
  display: block;
  padding: 5px var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wiki-tree a:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.wiki-tree a.active { color: var(--color-accent); background: var(--color-accent-light); font-weight: 500; }
.wiki-tree .toggle {
  position: absolute;
  left: -18px;
  top: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: transform .15s;
}
.wiki-tree li.has-children > ul { display: none; }
.wiki-tree li.has-children.expanded > ul { display: block; }
.wiki-tree li.has-children.expanded > .toggle { transform: rotate(90deg); }
.wiki-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  min-height: 400px;
}
.wiki-content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.wiki-page-title { font-size: var(--text-3xl); font-weight: 700; }
.wiki-page-meta  { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); }
.wiki-body       { line-height: 1.7; font-size: var(--text-base); }
.wiki-body h1, .wiki-body h2, .wiki-body h3 { font-weight: 700; margin: 1.5em 0 .5em; }
.wiki-body h1 { font-size: var(--text-2xl); }
.wiki-body h2 { font-size: var(--text-xl); }
.wiki-body h3 { font-size: var(--text-lg); }
.wiki-body p  { margin-bottom: 1em; }
.wiki-body ul, .wiki-body ol { padding-left: 1.5em; margin-bottom: 1em; list-style: revert; }
.wiki-body li { margin-bottom: .25em; }
.wiki-body blockquote { border-left: 3px solid var(--color-border-dark); padding-left: 1em; color: var(--color-text-muted); margin: 1em 0; }
.wiki-body pre, .wiki-body code { background: var(--color-bg); border-radius: var(--radius-sm); font-family: monospace; }
.wiki-body pre  { padding: var(--space-4); overflow-x: auto; margin: 1em 0; border: 1px solid var(--color-border); }
.wiki-body code { padding: 2px 5px; font-size: .9em; }
.wiki-body pre code { padding: 0; background: none; }
.wiki-body a { color: var(--color-accent); }
.wiki-body strong { font-weight: 600; }
.wiki-editor-wrap { }
.wiki-editor-wrap .tox-tinymce { border-radius: var(--radius-sm) !important; border-color: var(--color-border) !important; }

/* --- Task detail --- */
.task-detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: var(--space-6); align-items: start; }
.task-meta-card .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}
.task-meta-card .meta-row:last-child { border-bottom: none; }
.task-meta-card .meta-label { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 500; }
.task-id { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-2); }

/* Comments */
.comment-list { margin-top: var(--space-6); }
.comment-item {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-1); }
.comment-author { font-size: var(--text-sm); font-weight: 600; }
.comment-date { font-size: var(--text-xs); color: var(--color-text-muted); }
.comment-text { font-size: var(--text-sm); line-height: 1.6; background: var(--color-bg); padding: var(--space-3); border-radius: var(--radius-sm); }
.comment-form { margin-top: var(--space-6); border-top: 1px solid var(--color-border); padding-top: var(--space-6); }
.comment-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: 0;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.comment-item:hover .comment-delete-btn { opacity: 1; }
.comment-delete-btn:hover { color: var(--color-danger); }

/* --- Modal --- */
.fab-ticket {
  position: fixed;
  bottom: calc(var(--space-6) + 52px + 10px);
  right: var(--space-6);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform .15s, box-shadow .15s;
}
.fab-ticket:hover { transform: scale(1.08); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.fab-info {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #374151;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform .15s, box-shadow .15s;
}
.fab-info:hover { transform: scale(1.08); box-shadow: 0 8px 24px rgba(0,0,0,.18); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  margin: var(--space-4);
}
.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: var(--space-1); }
.modal-body    { padding: var(--space-6); }
.modal-footer  { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); display: flex; gap: var(--space-3); justify-content: flex-end; }

/* --- Utilities --- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.text-sm { font-size: var(--text-sm); }
.text-muted { color: var(--color-text-muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.color-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(0,0,0,.1); display: inline-block; }

/* --- Tabs --- */
.tabs {
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 0;
  margin-bottom: var(--space-6);
}
.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Icon picker --- */
.icon-picker {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.icon-picker-preview {
  font-size: 2.5rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.icon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.icon-option {
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .1s, border-color .1s;
  line-height: 1;
  padding: 0;
}
.icon-option:hover   { background: var(--color-bg); border-color: var(--color-border); }
.icon-option.selected { background: var(--color-accent-light); border-color: var(--color-accent-border); }

/* --- Auth layout --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-4);
}
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
}
.auth-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}
.auth-logo .logo-text {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-accent);
}
.auth-logo .logo-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.auth-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-accent); }
.breadcrumb-sep { color: var(--color-border-dark); }
.breadcrumb-current { color: var(--color-text); }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .task-detail-grid { grid-template-columns: 1fr; }
  .wiki-layout { grid-template-columns: 240px 1fr; }
}

/* ── Attachments ────────────────────────────────────────────── */
.attachment-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  transition: background .15s;
  min-width: 0;
}
.attachment-item:hover { background: var(--color-surface); }
.attachment-icon { font-size: 1.1rem; line-height: 1; flex-shrink: 0; }
.attachment-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.attachment-name {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-name:hover { text-decoration: underline; }
.attachment-meta { font-size: 0.65rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: .85rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity .15s, color .15s;
  line-height: 1;
}
.attachment-item:hover .attachment-delete-btn { opacity: 1; }
.attachment-delete-btn:hover { color: var(--color-danger); }
.attachment-share-btn {
  flex-shrink: 0;
  cursor: pointer;
  transition: filter .15s;
}
.attachment-share-btn:hover { filter: brightness(.95); }

/* ── Activity checklist ─────────────────────────────────────── */
.activity-progress-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-4);
}
.activity-progress-fill {
  height: 100%;
  background: var(--color-success);
  border-radius: var(--radius-full);
  transition: width .3s ease;
}
.activity-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.activity-item:last-child { border-bottom: none; }
.activity-drag-handle {
  cursor: grab;
  color: var(--color-text-muted);
  font-size: 1rem;
  flex-shrink: 0;
  opacity: .45;
  line-height: 1;
  padding: 2px 0;
}
.activity-drag-handle:hover { opacity: .85; }
.activity-checkbox {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-success);
}
.activity-label {
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.4;
  cursor: text;
  word-break: break-word;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: 0 -4px;
}
.activity-label.is-complete {
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.activity-label:hover { background: var(--color-bg); }
.activity-edit-input {
  flex: 1;
  font-size: var(--text-sm);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
}
.activity-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.activity-item:hover .activity-delete-btn { opacity: 1; }
.activity-delete-btn:hover { color: var(--color-danger); }
.activity-add-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.activity-add-input {
  flex: 1;
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color .15s;
}
.activity-add-input:focus { border-color: var(--color-accent); background: var(--color-surface); }
.activity-add-input::placeholder { color: var(--color-text-muted); }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    left: -280px;
    top: var(--header-h);
    width: 280px;
    height: calc(100vh - var(--header-h));
    z-index: 95;
    transition: left .25s;
    --sidebar-w: 280px;
  }
  .app-sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .app-content { grid-column: 1; padding: var(--space-4); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-tree { position: static; }
  .board-column { min-width: 200px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
