/* ============================================
   專案管理系統 — Design Tokens
   ============================================ */

:root {
  /* Type */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Light surfaces (warm neutral) */
  --bg: oklch(0.99 0.005 90);
  --bg-subtle: oklch(0.975 0.006 90);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.975 0.006 90);
  --surface-hover: oklch(0.965 0.008 90);
  --border: oklch(0.92 0.01 90);
  --border-strong: oklch(0.86 0.012 90);
  --divider: oklch(0.94 0.008 90);

  /* Text */
  --text-1: oklch(0.22 0.02 270);
  --text-2: oklch(0.42 0.02 270);
  --text-3: oklch(0.58 0.02 270);
  --text-inverse: oklch(0.99 0 0);

  /* Primary (tweakable) */
  --primary-h: 280;
  --primary: oklch(0.55 0.2 var(--primary-h));
  --primary-hover: oklch(0.48 0.2 var(--primary-h));
  --primary-soft: oklch(0.95 0.06 var(--primary-h));
  --primary-soft-text: oklch(0.4 0.18 var(--primary-h));

  /* Source brand-adjacent (kept distinct from any real product) */
  --source-jira: oklch(0.6 0.16 250);
  --source-jira-soft: oklch(0.95 0.04 250);
  --source-trello: oklch(0.66 0.14 215);
  --source-trello-soft: oklch(0.95 0.04 215);
  --source-native: var(--primary);
  --source-native-soft: var(--primary-soft);

  /* Semantic */
  --green: oklch(0.65 0.16 150);
  --green-soft: oklch(0.94 0.06 150);
  --blue: oklch(0.62 0.16 245);
  --blue-soft: oklch(0.95 0.05 245);
  --red: oklch(0.6 0.2 25);
  --red-soft: oklch(0.95 0.05 25);
  --orange: oklch(0.7 0.16 55);
  --orange-soft: oklch(0.96 0.06 55);
  --yellow: oklch(0.78 0.14 95);
  --yellow-soft: oklch(0.96 0.06 95);
  --purple: oklch(0.6 0.2 305);
  --purple-soft: oklch(0.95 0.05 305);
  --pink: oklch(0.7 0.18 350);
  --pink-soft: oklch(0.96 0.05 350);
  --teal: oklch(0.7 0.12 185);
  --teal-soft: oklch(0.95 0.04 185);
  --gray: oklch(0.55 0.01 270);
  --gray-soft: oklch(0.94 0.005 270);

  /* Radii / shadows */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.06);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.12);

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

[data-theme="dark"] {
  --bg: oklch(0.16 0.012 270);
  --bg-subtle: oklch(0.19 0.013 270);
  --surface: oklch(0.21 0.013 270);
  --surface-2: oklch(0.23 0.014 270);
  --surface-hover: oklch(0.26 0.015 270);
  --border: oklch(0.3 0.015 270);
  --border-strong: oklch(0.36 0.018 270);
  --divider: oklch(0.27 0.014 270);

  --text-1: oklch(0.97 0.005 270);
  --text-2: oklch(0.78 0.012 270);
  --text-3: oklch(0.6 0.015 270);

  --primary: oklch(0.7 0.18 var(--primary-h));
  --primary-hover: oklch(0.78 0.16 var(--primary-h));
  --primary-soft: oklch(0.32 0.12 var(--primary-h));
  --primary-soft-text: oklch(0.85 0.14 var(--primary-h));

  --source-jira: oklch(0.72 0.14 250);
  --source-jira-soft: oklch(0.32 0.1 250);
  --source-trello: oklch(0.75 0.13 215);
  --source-trello-soft: oklch(0.32 0.09 215);

  --green-soft: oklch(0.32 0.1 150);
  --blue-soft: oklch(0.32 0.1 245);
  --red-soft: oklch(0.34 0.1 25);
  --orange-soft: oklch(0.34 0.1 55);
  --yellow-soft: oklch(0.34 0.1 95);
  --purple-soft: oklch(0.32 0.1 305);
  --pink-soft: oklch(0.34 0.1 350);
  --teal-soft: oklch(0.32 0.08 185);
  --gray-soft: oklch(0.3 0.01 270);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.5);
}

/* ============================================
   Base
   ============================================ */
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }

/* ============================================
   App shell
   ============================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
}
.sidebar {
  grid-row: 1 / 3;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  grid-column: 2;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.main {
  grid-column: 2;
  overflow: auto;
  background: var(--bg);
}

/* ============================================
   Sidebar
   ============================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), oklch(0.65 0.2 calc(var(--primary-h) + 40)));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 14px;
}
.brand-name small { display: block; font-weight: 400; color: var(--text-3); font-size: 11px; letter-spacing: 0; }

.proj-switcher {
  margin: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.proj-switcher:hover { background: var(--surface-hover); }
.proj-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.proj-meta { flex: 1; min-width: 0; }
.proj-meta .name { font-weight: 600; font-size: 13px; }
.proj-meta .key { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

.nav { padding: 4px 8px; flex: 1; overflow-y: auto; }
.nav-section { padding: 12px 8px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  margin: 1px 0;
  user-select: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-1); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-3);
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-item.active .count { background: var(--primary); color: white; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================
   Topbar
   ============================================ */
.topbar .search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  width: 380px;
  cursor: text;
}
.topbar .search:focus-within { border-color: var(--primary); background: var(--surface); }
.topbar .search input { background: none; border: none; outline: none; flex: 1; font-size: 13px; }
.topbar .search kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-3);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  color: var(--text-2);
  position: relative;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-1); }
.icon-btn .dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}

/* ============================================
   Avatar
   ============================================ */
.avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.md { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-1); }
.btn-outline { border-color: var(--border-strong); color: var(--text-1); background: var(--surface); }
.btn-outline:hover { background: var(--surface-hover); }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ============================================
   Badges / chips
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  line-height: 1.4;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-yellow { background: var(--yellow-soft); color: oklch(0.45 0.14 80); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-pink { background: var(--pink-soft); color: var(--pink); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-gray { background: var(--gray-soft); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary-soft-text); }

/* Source pills */
.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px 2px 4px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.source-pill-square {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: grid; place-items: center;
  color: white;
  font-size: 9px;
  font-weight: 800;
}
.source-jira { background: var(--source-jira-soft); color: var(--source-jira); }
.source-jira .source-pill-square { background: var(--source-jira); }
.source-trello { background: var(--source-trello-soft); color: var(--source-trello); }
.source-trello .source-pill-square { background: var(--source-trello); }
.source-native { background: var(--primary-soft); color: var(--primary-soft-text); }
.source-native .source-pill-square { background: var(--primary); }

/* Issue type icon */
.type-icon {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: inline-grid; place-items: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.type-icon.story { background: var(--green); }
.type-icon.task { background: var(--blue); }
.type-icon.bug { background: var(--red); }
.type-icon.epic { background: var(--purple); }
.type-icon.subtask { background: var(--teal); }

/* Priority */
.priority { display: inline-flex; gap: 1px; align-items: end; height: 12px; }
.priority span { width: 3px; background: var(--border-strong); border-radius: 1px; }
.priority span:nth-child(1) { height: 4px; }
.priority span:nth-child(2) { height: 8px; }
.priority span:nth-child(3) { height: 12px; }
.priority.p-highest span { background: var(--red); }
.priority.p-high span:nth-child(-n+3) { background: var(--orange); }
.priority.p-high span:nth-child(3) { background: var(--border-strong); }
.priority.p-medium span:nth-child(-n+2) { background: var(--yellow); }
.priority.p-low span:nth-child(1) { background: var(--blue); }
.priority.p-lowest span { background: var(--gray); }

/* Issue key */
.issue-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}

/* ============================================
   Page header
   ============================================ */
.page {
  padding: 20px 28px;
  max-width: 100%;
}
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 2px;
}
.page-subtitle { color: var(--text-3); font-size: 13px; }
.page-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.crumbs { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.crumbs span + span::before { content: "/"; margin: 0 6px; opacity: 0.5; }

/* ============================================
   Card / generic surfaces
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-padded { padding: 16px; }
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title { font-weight: 600; font-size: 14px; }

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ============================================
   Filters bar
   ============================================ */
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  background: var(--surface);
}
.filter-chip:hover { border-style: solid; color: var(--text-1); }
.filter-chip.active { background: var(--primary-soft); color: var(--primary-soft-text); border-color: transparent; border-style: solid; }

/* ============================================
   Backlog list / Sprint
   ============================================ */
.sprint-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
}
.sprint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--divider);
}
.sprint-chev { color: var(--text-3); cursor: pointer; transition: transform 0.15s; }
.sprint-chev.open { transform: rotate(90deg); }
.sprint-title { font-weight: 600; font-size: 14px; }
.sprint-meta { color: var(--text-3); font-size: 12px; }
.sprint-status-pills { display: inline-flex; gap: 4px; }
.status-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.status-pill.todo { background: var(--gray-soft); color: var(--text-2); }
.status-pill.progress { background: var(--blue-soft); color: var(--blue); }
.status-pill.done { background: var(--green-soft); color: var(--green); }

.sprint-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.issue-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  cursor: pointer;
  position: relative;
  min-height: 44px;
}
.issue-row:hover { background: var(--surface-hover); }
.issue-row:last-child { border-bottom: none; }
.issue-row.dragging { opacity: 0.4; }
.issue-row.drag-over { box-shadow: inset 0 2px 0 var(--primary); }
.issue-row.pending { opacity: 0.55; pointer-events: none; }
.issue-row .grip {
  color: var(--border-strong);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.1s;
}
.issue-row:hover .grip { opacity: 1; }
.issue-row-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.issue-row-line1 {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.issue-row-line2 {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  flex-wrap: nowrap; overflow: hidden;
}
.issue-row .title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; font-size: 14px;
  flex: 1; min-width: 0; line-height: 1.4;
}
.issue-row-desc {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; min-width: 0; flex: 1;
}
.issue-row-meta {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.issue-row .labels { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.issue-row .estimate {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 1px 8px;
  border-radius: 10px;
  text-align: center;
  font-weight: 600;
}
.issue-row .estimate.zero { background: transparent; color: var(--text-3); border: 1px dashed var(--border-strong); }

.drop-container { min-height: 8px; }
.sprint-empty.drop-active {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary) 8%, var(--surface));
  color: var(--primary);
  font-weight: 600;
}
.sprint-empty {
  padding: 18px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  border: 1.5px dashed var(--border);
  margin: 10px;
  border-radius: var(--radius-md);
}

/* ============================================
   Board / Kanban
   ============================================ */
.board-wrap { padding: 16px 28px 28px; overflow-x: auto; }
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 300px;
  gap: 14px;
  min-height: calc(100vh - 180px);
}
.board-col {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
}
.board-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.board-col-header .count {
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-2);
  font-weight: 700;
  margin-left: auto;
}
.board-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.1s, transform 0.1s;
}
.kcard:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.kcard.dragging { opacity: 0.4; }
.kcard-labels { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.kcard-mini-label { height: 4px; border-radius: 2px; min-width: 32px; }
.kcard-title { font-size: 14px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; word-break: break-word; color: var(--text-1); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kcard-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-3); }
.kcard-meta .left { display: flex; align-items: center; gap: 6px; flex: 1; }
.kcard-meta .right { display: flex; align-items: center; gap: 6px; }
.kcard-meta .meta-num { font-family: var(--font-mono); }
.kcard.drag-over { box-shadow: inset 0 0 0 2px var(--primary); }

.col-add {
  padding: 6px 10px;
  margin: 2px 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.col-add:hover { background: var(--surface-hover); color: var(--text-1); }

/* ============================================
   Modal
   ============================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.4);
  z-index: 50;
  display: grid; place-items: center;
  padding: 40px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 980px; width: 100%;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-body { display: grid; grid-template-columns: 1fr 280px; overflow: hidden; flex: 1; }
.modal-main { padding: 18px 22px; overflow-y: auto; }
.modal-side { border-left: 1px solid var(--divider); padding: 16px; overflow-y: auto; background: var(--bg-subtle); }

.issue-detail-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 4px 0 16px;
}
.issue-detail-title:focus { outline: none; background: var(--primary-soft); border-radius: 4px; }
.detail-section { margin-bottom: 22px; }
.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.detail-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-1);
}
.detail-desc p { margin: 0 0 8px; }
.detail-side-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--divider); font-size: 13px; }
.detail-side-row:last-child { border-bottom: none; }
.detail-side-row .k { width: 90px; color: var(--text-3); font-size: 12px; }
.detail-side-row .v { flex: 1; }

.subtask-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: 13px;
}
.subtask-row:hover { background: var(--surface-hover); }
.subtask-check {
  width: 14px; height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: white;
}
.subtask-check.done { background: var(--green); border-color: var(--green); }
.subtask-row.done .title { color: var(--text-3); text-decoration: line-through; }

.comment {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.comment:last-child { border-bottom: none; }
.comment-body { flex: 1; }
.comment-meta { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.comment-meta strong { color: var(--text-1); font-weight: 600; margin-right: 6px; }
.comment-text { font-size: 13px; line-height: 1.55; }

.comment-composer {
  display: flex; gap: 10px; padding: 12px 0;
}
.comment-composer .input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--surface);
  resize: vertical;
  min-height: 36px;
}
.comment-composer .input:focus { outline: none; border-color: var(--primary); }

/* ============================================
   Dashboard
   ============================================ */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.dash-grid > * { min-width: 0; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat .label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-feature-settings: "tnum"; }
.stat .trend { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.spark {
  height: 36px;
  margin-top: -8px;
}

/* ============================================
   Roadmap / Gantt
   ============================================ */
.roadmap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.roadmap-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
}
.roadmap-side { border-right: 1px solid var(--border); }
.roadmap-scroll { overflow-x: auto; position: relative; }
.roadmap-headerrow {
  height: 36px;
  display: flex;
  align-items: stretch;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  border-bottom: 1px solid var(--divider);
  background: var(--bg-subtle);
}
.roadmap-month {
  border-right: 1px solid var(--divider);
  display: flex;
  align-items: center;
  padding-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 100px;
}
.roadmap-row {
  height: 44px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  font-size: 13px;
  position: relative;
}
.roadmap-row.epic-row { background: var(--surface-2); font-weight: 600; }
.roadmap-bar-track { position: relative; }
.roadmap-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.roadmap-bar .progress {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: oklch(0 0 0 / 0.18);
  border-radius: 6px 0 0 6px;
}
.roadmap-bar.story { height: 14px; font-size: 0; }
.roadmap-today {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--red);
  pointer-events: none;
  z-index: 2;
}
.roadmap-today::after {
  content: "Today";
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--red);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ============================================
   Reports / charts
   ============================================ */
.chart-card { padding: 16px; }
.chart-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.chart-sub { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); align-items: center; flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ============================================
   Integrations
   ============================================ */
.integration-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.integration-logo {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.integration-logo.jira { background: var(--source-jira); }
.integration-logo.trello { background: var(--source-trello); }
.integration-logo.github { background: oklch(0.3 0.01 270); }
.integration-logo.slack { background: oklch(0.65 0.18 330); }
.integration-logo.figma { background: oklch(0.6 0.2 30); }
.integration-meta h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.integration-meta p { margin: 0; font-size: 12px; color: var(--text-3); }
.integration-meta { flex: 1; }
.sync-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 4px;
  vertical-align: 0;
  position: relative;
}
.sync-dot.warn { background: var(--orange); }
.sync-dot.err { background: var(--red); }
.sync-dot.syncing { background: var(--blue); }
.sync-dot.syncing::before {
  content: "";
  position: absolute; inset: -2px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0.3;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: 0.4; } 100% { transform: scale(2); opacity: 0; } }

/* Mapping table */
.mapping-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.mapping-row {
  display: grid;
  grid-template-columns: 1fr 40px 1fr 100px 28px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
}
.mapping-row.head {
  background: var(--bg-subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.mapping-row:last-child { border-bottom: none; }
.mapping-side {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.mapping-arrow {
  text-align: center;
  color: var(--text-3);
}

/* ============================================
   Form fields
   ============================================ */
.field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px;
}
.field label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }

/* ============================================
   Utilities
   ============================================ */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.tnum { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--divider); margin: 8px 0; }
.fade-in { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================
   Toast
   ============================================ */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideIn 0.2s ease;
}
.toast.info { border-left-color: var(--blue); }
.toast.warn { border-left-color: var(--orange); }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================
   Conflict resolver
   ============================================ */
.diff-pair {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}
.diff-side {
  padding: 12px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.diff-side:hover { background: var(--surface-hover); }
.diff-side.picked {
  background: var(--primary-soft);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.diff-side .field-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.diff-side .field-value { font-size: 13px; }
.diff-vs { display: grid; place-items: center; background: var(--bg-subtle); color: var(--text-3); font-size: 11px; font-weight: 700; }

/* ============================================
   Automation
   ============================================ */
.automation-flow {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flow-node {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
}
.flow-node .badge { margin-left: auto; }
.flow-arrow { text-align: center; color: var(--text-3); font-size: 16px; line-height: 1; }
.flow-node-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: white;
}
.flow-trigger .flow-node-icon { background: var(--blue); }
.flow-condition .flow-node-icon { background: var(--orange); }
.flow-action .flow-node-icon { background: var(--green); }

/* ============================================
   Tweaks panel position tweak
   ============================================ */
.tweaks-panel { z-index: 90; }
