/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }
h1, h2, h3 { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ============================================================
   DESIGN TOKENS — DARK (default)
   ============================================================ */
:root {
  color-scheme: dark;
  --bg:          #0a1020;
  --surface:     #0f172a;
  --surface-alt: #080d1a;
  --border:      #1a2236;
  --border-md:   #1e293b;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-faint:  #475569;
  --text-ghost:  #334155;
  --accent:      #a78bfa;
  --accent-bg:   #1e1b4b;
  --accent-dim:  #4c1d95;
  --success:     #4ade80;
  --warning:     #fbbf24;
  --danger:      #f87171;
  --danger-bg:   #450a0a;
  --danger-dim:  #7f1d1d;
  --scrollbar-thumb:       #1e293b;
  --scrollbar-thumb-hover: #334155;
  --scrollbar-track:       transparent;
}

/* ============================================================
   DESIGN TOKENS — LIGHT
   ============================================================ */
[data-theme="light"] {
  color-scheme: light;
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface-alt: #ffffff;
  --border:      #e2e8f0;
  --border-md:   #f1f5f9;
  --text:        #1e293b;
  --text-muted:  #6b7280;
  --text-faint:  #9ca3af;
  --text-ghost:  #d1d5db;
  --accent:      #3b82f6;
  --accent-bg:   #eff6ff;
  --accent-dim:  #bfdbfe;
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --danger-dim:  #fecaca;
  --scrollbar-thumb:       #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
  --scrollbar-track:       transparent;
}

/* ============================================================
   SCROLLBARS — theme-aware
   ============================================================ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  flex-shrink: 0;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 20px;
}

/* ============================================================
   SCREEN NAV (mockup navigation strip)
   ============================================================ */
.screen-nav {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.screen-nav a {
  color: var(--text-ghost);
  font-size: 11px;
  padding: 6px 10px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  display: inline-block;
}

.screen-nav a:hover { color: var(--text-faint); }
.screen-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.screen-nav .sn-label { color: var(--border-md); font-size: 10px; margin-right: 4px; }

/* ============================================================
   THEME TOGGLE BAR
   ============================================================ */
.theme-bar {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-md);
  padding: 5px 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.theme-btn {
  background: var(--border-md);
  border: 1px solid var(--text-ghost);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}

.theme-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   SIDEBAR — LOGO
   ============================================================ */
.sidebar-logo {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  flex-shrink: 0;
}

[data-theme="light"] .logo-mark {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.logo-text {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* ============================================================
   SIDEBAR — NAV ITEMS
   ============================================================ */
.sidebar-section { padding: 10px 8px 4px; }

.sidebar-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 0 6px;
}

/* Lone top-level links (e.g. Dashboard) align with section headers, not nav items. */
.sidebar-section > .nav-item:only-child {
  padding-left: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 1px;
  text-decoration: none;
  font-size: 12px;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.nav-icon {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-icon.circle { border-radius: 50%; }

.nav-badge {
  margin-left: auto;
  background: var(--border-md);
  color: var(--text-muted);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
}

.nav-badge.accent {
  background: var(--accent-bg);
  color: var(--accent);
}

/* ============================================================
   SIDEBAR — USER FOOTER
   ============================================================ */
.sidebar-spacer { flex: 1; }

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

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 9px;
  color: var(--text-muted);
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #0f172a;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

.btn-ghost {
  background: var(--border-md);
  color: var(--text-muted);
  border: 1px solid var(--text-ghost);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-dim);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  display: inline-block;
}

/* Dark status colours */
.s-backlog    { background: #1e293b; color: #64748b; }
.s-todo       { background: #1c2039; color: #818cf8; }
.s-inprogress { background: #1e1b4b; color: #a78bfa; }
.s-inreview   { background: #1a2d3a; color: #22d3ee; }
.s-testing    { background: #1a2e22; color: #4ade80; }
.s-done       { background: #162412; color: #86efac; }
.s-closed     { background: #1e293b; color: #475569; }

/* Light status colours */
[data-theme="light"] .s-backlog    { background: #f1f5f9; color: #9ca3af; }
[data-theme="light"] .s-todo       { background: #eef2ff; color: #6366f1; }
[data-theme="light"] .s-inprogress { background: #f5f3ff; color: #7c3aed; }
[data-theme="light"] .s-inreview   { background: #ecfeff; color: #0e7490; }
[data-theme="light"] .s-testing    { background: #f0fdf4; color: #16a34a; }
[data-theme="light"] .s-done       { background: #dcfce7; color: #15803d; }
[data-theme="light"] .s-closed     { background: #f1f5f9; color: #9ca3af; }

/* ============================================================
   PRIORITY DOTS
   ============================================================ */
.pdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.p-blocker  { background: #ef4444; }
.p-critical { background: #f97316; }
.p-high     { background: #fbbf24; }
.p-medium   { background: #a78bfa; }
.p-low      { background: #475569; }
.p-none     { background: transparent; border: 1px solid #334155; }

/* ============================================================
   TAGS / LABELS
   ============================================================ */
.tag {
  background: var(--border);
  color: var(--text-faint);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

.label-chip {
  background: var(--border);
  color: var(--text-faint);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-block;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.search-box {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 5px;
  padding: 5px 10px;
  color: var(--text-muted);
  font-size: 11px;
  width: 200px;
  outline: none;
  font-family: inherit;
}

.filter-bar {
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-chip.on {
  background: var(--accent-bg);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.chip-label { color: var(--text-ghost); font-size: 10px; }

.filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border-md);
  margin: 0 2px;
}

.count-label {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
}

.status-select {
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 5px;
  padding: 5px 10px;
  color: var(--accent);
  font-size: 12px;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.panel-action {
  font-size: 10px;
  color: var(--text-faint);
  cursor: pointer;
}

.panel-sub { font-size: 10px; color: var(--text-faint); }

/* ============================================================
   STAT TILES
   ============================================================ */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-sub { font-size: 10px; color: var(--text-faint); }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar {
  height: 5px;
  background: var(--border-md);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
}

/* ============================================================
   KANBAN CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 7px;
  padding: 10px 12px;
  cursor: grab;
}

.card:hover { border-color: var(--text-ghost); }

.card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.card-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 9px;
  color: var(--text-faint);
}

.card-title {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-label {
  background: var(--border);
  color: var(--text-faint);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}

.card-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  margin-left: auto;
  flex-shrink: 0;
}

.card-due { font-size: 9px; color: var(--text-faint); }
.card-due.overdue { color: var(--danger); }

/* ============================================================
   KANBAN BOARD COLUMNS
   ============================================================ */
.board-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  background: var(--bg);
}

.col {
  width: 230px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.col-header {
  padding: 8px 10px;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.col-name { font-size: 11px; font-weight: 600; }

.col-count {
  font-size: 10px;
  background: var(--surface);
  border-radius: 8px;
  padding: 1px 6px;
  color: var(--text-faint);
  margin-left: auto;
}

.col-add { font-size: 16px; color: var(--text-ghost); cursor: pointer; line-height: 1; }
.col-add:hover { color: var(--text-faint); }
.col-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

/* Dark column accent headers */
.col-backlog    .col-header { background: #0f172a; }
.col-backlog    .col-name   { color: #64748b; }
.col-todo       .col-header { background: #13152a; }
.col-todo       .col-name   { color: #818cf8; }
.col-inprogress .col-header { background: #150f30; }
.col-inprogress .col-name   { color: #a78bfa; }
.col-inreview   .col-header { background: #0f1f2a; }
.col-inreview   .col-name   { color: #22d3ee; }
.col-testing    .col-header { background: #0f1f15; }
.col-testing    .col-name   { color: #4ade80; }
.col-done       .col-header { background: #0d1e10; }
.col-done       .col-name   { color: #86efac; }
.col-closed     .col-header { background: #0f172a; }
.col-closed     .col-name   { color: #475569; }

/* Light column accent headers */
[data-theme="light"] .col-backlog    .col-header { background: #f1f5f9; }
[data-theme="light"] .col-backlog    .col-name   { color: #9ca3af; }
[data-theme="light"] .col-todo       .col-header { background: #eef2ff; }
[data-theme="light"] .col-todo       .col-name   { color: #6366f1; }
[data-theme="light"] .col-inprogress .col-header { background: #f5f3ff; }
[data-theme="light"] .col-inprogress .col-name   { color: #7c3aed; }
[data-theme="light"] .col-inreview   .col-header { background: #ecfeff; }
[data-theme="light"] .col-inreview   .col-name   { color: #0e7490; }
[data-theme="light"] .col-testing    .col-header { background: #f0fdf4; }
[data-theme="light"] .col-testing    .col-name   { color: #16a34a; }
[data-theme="light"] .col-done       .col-header { background: #dcfce7; }
[data-theme="light"] .col-done       .col-name   { color: #15803d; }
[data-theme="light"] .col-closed     .col-header { background: #f1f5f9; }
[data-theme="light"] .col-closed     .col-name   { color: #9ca3af; }

/* ============================================================
   ISSUE DETAIL — TWO-COLUMN LAYOUT
   ============================================================ */
.detail-main {
  flex: 1;
  min-width: 0;
  padding: 20px 24px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.detail-sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 16px;
  overflow-y: auto;
}

/* ============================================================
   ISSUE TABLE
   ============================================================ */
.issue-table { width: 100%; border-collapse: collapse; }

.issue-table thead th {
  padding: 9px 12px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

.issue-table thead th:hover { color: var(--text-muted); }
.issue-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
.issue-table tbody tr:hover { background: var(--surface); }
.issue-table tbody td { padding: 9px 12px; vertical-align: middle; }

.issue-id-cell {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
}

.issue-title-cell { color: var(--text-muted); font-size: 12px; max-width: 340px; }
.issue-title-cell a { color: inherit; text-decoration: none; }
.issue-title-cell a:hover { color: var(--accent); }

.due-cell { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.due-cell.overdue { color: var(--danger); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.pg-btn {
  background: var(--surface);
  border: 1px solid var(--border-md);
  color: var(--text-faint);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}

.pg-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.pg-spacer { flex: 1; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-ghost); }
.breadcrumb .current { color: var(--text-muted); }

/* ============================================================
   BOARD FILTER TOOLBAR
   ============================================================ */
.board-toolbar {
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ============================================================
   PROJECT OVERVIEW — CLIENT HEADER
   ============================================================ */
.client-header {
  background: linear-gradient(135deg, #13092e 0%, #0d1a30 100%);
  border: 1px solid #2d1f5e;
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

[data-theme="light"] .client-header {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-color: #bfdbfe;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #162412;
  border: 1px solid #166534;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #4ade80;
}

[data-theme="light"] .health-badge {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #16a34a;
}

.health-badge.at-risk { background: #422006; border-color: #92400e; color: #fbbf24; }
.health-badge.behind  { background: #450a0a; border-color: #991b1b; color: #f87171; }

[data-theme="light"] .health-badge.at-risk { background: #fffbeb; border-color: #fde68a; color: #d97706; }
[data-theme="light"] .health-badge.behind  { background: #fef2f2; border-color: #fecaca; color: #dc2626; }

.health-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Milestone status chips */
.ms-status { font-size: 9px; padding: 2px 8px; border-radius: 10px; }
.ms-on-track { background: #162412; color: #4ade80; }
.ms-at-risk  { background: #422006; color: #fbbf24; }
.ms-behind   { background: #450a0a; color: #f87171; }

[data-theme="light"] .ms-on-track { background: #f0fdf4; color: #16a34a; }
[data-theme="light"] .ms-at-risk  { background: #fffbeb; color: #d97706; }
[data-theme="light"] .ms-behind   { background: #fef2f2; color: #dc2626; }

/* Completion checkmark */
.check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #162412;
  border: 1.5px solid #4ade80;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 8px;
  color: #4ade80;
}

[data-theme="light"] .check { background: #f0fdf4; border-color: #86efac; color: #16a34a; }

/* Upcoming event badges */
.upcoming-badge { font-size: 9px; padding: 1px 7px; border-radius: 8px; }
.ub-milestone { background: #1e1b4b; color: #a78bfa; }
.ub-deadline  { background: #422006; color: #fbbf24; }

[data-theme="light"] .ub-milestone { background: #f5f3ff; color: #7c3aed; }
[data-theme="light"] .ub-deadline  { background: #fffbeb; color: #d97706; }

/* Client note block */
.client-note {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 16px 20px;
}

.client-note-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-ghost);
  margin-bottom: 8px;
}

.client-note-text { font-size: 12px; color: var(--text-faint); line-height: 1.7; }

/* ============================================================
   GLOBAL LINKS
   ============================================================ */
a { color: var(--accent); }

/* ============================================================
   PM DOC — work item / comment rich-text rendering
   Editor content (ProseMirror output) + read-only display.
   Code blocks are opaque so they remain readable on cards.
   HLJS stylesheet is swapped by theme.js (github vs github-dark).
   ============================================================ */
.pm-doc-readonly,
.issuepilot-pm-root {
  min-width: 0;
  max-width: 100%;
}
.pm-doc-readonly figure,
.issuepilot-pm-root figure {
  max-width: 100%;
  margin: 0.5rem 0;
}
.pm-doc-readonly img,
.issuepilot-pm-root img {
  max-width: 100%;
  height: auto;
  display: block;
}
.pm-doc-readonly pre,
.issuepilot-pm-root pre {
  position: relative;
  box-sizing: border-box;
  margin: 0.65rem 0;
  padding: 1.55rem 0.75rem 0.65rem;
  background: #343a45;
  color: #e9edf5;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.45;
  max-width: 100%;
}
html[data-theme="light"] .pm-doc-readonly pre,
html[data-theme="light"] .issuepilot-pm-root pre {
  background: #3d434e;
  color: #f2f4f8;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.pm-doc-readonly pre::before,
.issuepilot-pm-root pre::before {
  content: "Code";
  position: absolute;
  top: 0.45rem;
  left: 0.65rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(233, 237, 245, 0.5);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.2;
  pointer-events: none;
}
html[data-theme="light"] .pm-doc-readonly pre::before,
html[data-theme="light"] .issuepilot-pm-root pre::before {
  color: rgba(242, 244, 248, 0.55);
}
.pm-doc-readonly pre code,
.issuepilot-pm-root pre code {
  display: block;
  background: none;
  padding: 0;
  border-radius: 0;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: inherit;
  color: inherit;
  white-space: pre;
  border: none;
}
.pm-doc-readonly pre code.hljs {
  background: transparent !important;
}
.pm-doc-readonly p:has(> code:only-child) > code.hljs {
  background: #343a45 !important;
}
html[data-theme="light"] .pm-doc-readonly p:has(> code:only-child) > code.hljs {
  background: #3d434e !important;
}
.pm-doc-readonly p:has(> code:only-child),
.issuepilot-pm-root p:has(> code:only-child) {
  margin-top: 0;
  margin-bottom: 0;
}
.pm-doc-readonly p:has(> code:only-child):not(p:has(> code:only-child) + p),
.issuepilot-pm-root p:has(> code:only-child):not(p:has(> code:only-child) + p) {
  margin-top: 0.65rem;
}
.pm-doc-readonly p:has(> code:only-child):not(:has(+ p:has(> code:only-child))),
.issuepilot-pm-root p:has(> code:only-child):not(:has(+ p:has(> code:only-child))) {
  margin-bottom: 0.65rem;
}
.pm-doc-readonly p:has(> code:only-child) > code,
.issuepilot-pm-root p:has(> code:only-child) > code {
  position: relative;
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  background: #343a45;
  color: #e9edf5;
  padding: 0.4em 0.65em;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.88em;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
html[data-theme="light"] .pm-doc-readonly p:has(> code:only-child) > code,
html[data-theme="light"] .issuepilot-pm-root p:has(> code:only-child) > code {
  background: #3d434e;
  color: #f2f4f8;
  border-color: rgba(0, 0, 0, 0.2);
}
.pm-doc-readonly p:has(> code:only-child) + p:has(> code:only-child) > code,
.issuepilot-pm-root p:has(> code:only-child) + p:has(> code:only-child) > code {
  border-top: none;
  padding-top: 0.2em;
}
.pm-doc-readonly p:has(> code:only-child):not(p:has(> code:only-child) + p) > code,
.issuepilot-pm-root p:has(> code:only-child):not(p:has(> code:only-child) + p) > code {
  border-top-left-radius: 0.45rem;
  border-top-right-radius: 0.45rem;
  padding-top: 1.5em;
}
.pm-doc-readonly p:has(> code:only-child):not(:has(+ p:has(> code:only-child))) > code,
.issuepilot-pm-root p:has(> code:only-child):not(:has(+ p:has(> code:only-child))) > code {
  border-bottom-left-radius: 0.45rem;
  border-bottom-right-radius: 0.45rem;
  padding-bottom: 0.55em;
}
.pm-doc-readonly p:has(> code:only-child):not(p:has(> code:only-child) + p) > code::before,
.issuepilot-pm-root p:has(> code:only-child):not(p:has(> code:only-child) + p) > code::before {
  content: "Code";
  position: absolute;
  top: 0.4rem;
  left: 0.65rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(233, 237, 245, 0.5);
  font-family: "Segoe UI", system-ui, sans-serif;
  pointer-events: none;
}
html[data-theme="light"] .pm-doc-readonly p:has(> code:only-child):not(p:has(> code:only-child) + p) > code::before,
html[data-theme="light"] .issuepilot-pm-root p:has(> code:only-child):not(p:has(> code:only-child) + p) > code::before {
  color: rgba(242, 244, 248, 0.55);
}
.pm-doc-readonly p:not(:has(> code:only-child)) code,
.issuepilot-pm-root p:not(:has(> code:only-child)) code,
.pm-doc-readonly h2 code,
.pm-doc-readonly h3 code,
.issuepilot-pm-root h2 code,
.issuepilot-pm-root h3 code {
  background: #343a45;
  color: #e9edf5;
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.9em;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-theme="light"] .pm-doc-readonly p:not(:has(> code:only-child)) code,
html[data-theme="light"] .issuepilot-pm-root p:not(:has(> code:only-child)) code,
html[data-theme="light"] .pm-doc-readonly h2 code,
html[data-theme="light"] .pm-doc-readonly h3 code,
html[data-theme="light"] .issuepilot-pm-root h2 code,
html[data-theme="light"] .issuepilot-pm-root h3 code {
  background: #3d434e;
  color: #f2f4f8;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ============================================================
   ISSUEPILOT — WORKSPACE SHELL ADJUSTMENTS
   Template's `.content` has padding and owns its own scroll. The
   workspace app uses a flex-column main with the list/detail
   two-pane inside — so override padding defaults here.
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ============================================================
   ISSUEPILOT — SIDEBAR WORKSPACE SWITCHER
   Click-to-open dropdown that replaces the logo when the signed-in
   user belongs to more than one workspace. Powered by Alpine.
   ============================================================ */
.sidebar-workspace-switcher {
  position: relative;
  z-index: 20;
}
.sidebar-workspace-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sidebar-workspace-trigger:hover .logo-text {
  color: var(--accent);
}
.sidebar-workspace-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.sidebar-workspace-chevron {
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  flex-shrink: 0;
}
.workspace-switcher-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 100%;
  margin-top: 4px;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 6px;
  max-height: min(50vh, 18rem);
  overflow-y: auto;
}
.workspace-switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
}
.workspace-switcher-item:hover,
.workspace-switcher-item:focus-visible {
  background: var(--accent-bg);
  color: var(--accent);
  outline: none;
}
.workspace-switcher-item--current {
  background: var(--accent-bg);
  color: var(--accent);
}
.workspace-switcher-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.workspace-switcher-item-role {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}
.workspace-switcher-item:hover .workspace-switcher-item-role,
.workspace-switcher-item:focus-visible .workspace-switcher-item-role {
  color: var(--accent);
}

/* ============================================================
   ISSUEPILOT — NAV ITEM WITH RIGHT-SIDE COUNT
   Sidebar links that pair a label with a numeric badge (Work
   Items, Queue). Base .nav-item is a flex row already.
   ============================================================ */
.nav-item-with-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-sublabel {
  color: var(--text-muted);
  font-size: 10px;
  margin: 8px 8px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Hide the whole Filters section when it has no saved-filter rows and the
   "+" (save-new) control is not currently shown. */
.saved-filter-nav:not(:has(.saved-filter-row)):not(:has([data-saved-filter-add]:not([hidden]))) {
  display: none;
}

/* Filters section header: "Filters" label + right-aligned "+" save control. */
.saved-filter-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.saved-filter-nav-header .sidebar-sublabel,
.sidebar-section > .sidebar-sublabel {
  display: block;
  margin: 8px 0 4px;
  padding: 0;
}

/* Per-row layout: label flexes; gear then count sit in a trailing actions group. */
.saved-filter-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}
.saved-filter-row > .nav-item {
  flex: 1;
  min-width: 0;
}
.saved-filter-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding-right: 4px;
}
.saved-filter-row-menu {
  position: relative;
}
.saved-filter-gear {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  background: var(--surface);
  color: var(--text-muted);
}
.saved-filter-gear::-webkit-details-marker {
  display: none;
}
.saved-filter-row:hover .saved-filter-gear,
.saved-filter-row:focus-within .saved-filter-gear,
.saved-filter-row-menu[open] .saved-filter-gear {
  opacity: 1;
  visibility: visible;
}
.saved-filter-gear-icon {
  width: 12px;
  height: 12px;
  background: currentColor;
  /* gear/cog glyph via mask so it inherits currentColor */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.14 12.94a7.49 7.49 0 0 0 0-1.88l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.3 7.3 0 0 0-1.62-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54c-.59.24-1.13.56-1.62.94l-2.39-.96a.5.5 0 0 0-.61.22L2.27 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.49 7.49 0 0 0 0 1.88l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96c.49.38 1.03.7 1.62.94l.36 2.54a.5.5 0 0 0 .5.42h3.84a.5.5 0 0 0 .5-.42l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58ZM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7Z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.14 12.94a7.49 7.49 0 0 0 0-1.88l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.3 7.3 0 0 0-1.62-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54c-.59.24-1.13.56-1.62.94l-2.39-.96a.5.5 0 0 0-.61.22L2.27 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.49 7.49 0 0 0 0 1.88l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96c.49.38 1.03.7 1.62.94l.36 2.54a.5.5 0 0 0 .5.42h3.84a.5.5 0 0 0 .5-.42l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58ZM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* "+" save-new trigger on the Filters header. */
.saved-filter-add {
  position: relative;
}
.saved-filter-add-trigger {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-md);
  cursor: pointer;
  list-style: none;
}
.saved-filter-add-trigger::-webkit-details-marker {
  display: none;
}
.saved-filter-add-trigger:hover {
  color: var(--accent);
}

/* Flyout panel anchored to the right of the narrow sidebar so it is not
   clipped (reuses .saved-filter-menu-panel look from the old toolbar menus). */
.saved-filter-menu-panel--right {
  left: auto;
  right: 0;
}
.saved-filter-row-menu .saved-filter-menu-panel,
.saved-filter-add .saved-filter-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  z-index: 200;
}
.saved-filter-menu-action {
  font: inherit;
  font-size: 12px;
  text-align: left;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ============================================================
   ISSUEPILOT — SIGNED-IN USER FOOTER
   Sidebar bottom block with user email + sign-out link. Uses
   template's .sidebar-user pattern but trimmed (no avatar box).
   ============================================================ */
.sidebar-user .user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.sidebar-user .user-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-user .user-signout {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
}
.sidebar-user .user-signout:hover {
  color: var(--accent);
}
.sidebar-user .user-version {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   ISSUEPILOT — TWO-PANE LIST + DETAIL
   Queue, work items, and project detail render a list column on
   the left with an Alpine-Ajax-swapped detail pane on the right.
   Height is the viewport minus topbar; inner columns scroll.
   ============================================================ */
.two-pane {
  display: grid;
  grid-template-columns: 640px 1fr;
  gap: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}
.two-pane-list-wrap {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.two-pane-list-wrap > .list-col {
  flex: 1;
  min-height: 0;
}
.list-col {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.list-col-header {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}
.list-col-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  z-index: 0;
}
.list-col-row {
  border-bottom: 1px solid var(--border);
}
.list-col-row[data-workitem-ref] {
  cursor: pointer;
}
.list-col-row--current {
  background: var(--accent-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}
.detail-pane {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  background: var(--bg);
}
.detail-pane > * {
  min-width: 0;
  box-sizing: border-box;
}
.workitem-detail-shell {
  width: 100%;
  max-width: 680px;
  box-sizing: border-box;
}
.two-pane:has(> .two-pane-list-wrap) .detail-pane {
  align-items: stretch;
}
.two-pane:has(> .two-pane-list-wrap) .workitem-detail-shell {
  max-width: none;
}
/* Escape parent padding so the two-pane fills the main area edge-to-edge.
   The negative margin cancels .content's 20px padding (workspace + portal). */
.two-pane--flush {
  margin: -20px;
}

/* ============================================================
   ISSUEPILOT — AUTH (sign-in page)
   Centered panel shell with brand row, sign-in form, and a
   hint block. Standalone — does not extend any other base.
   ============================================================ */
.auth-shell {
  width: min(440px, 100%);
  position: relative;
  z-index: 1;
  margin: 24px auto;
}
.auth-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-mark {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  font-weight: 700;
}
[data-theme="light"] .auth-mark {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}
.auth-brand h2 {
  font-size: 17px;
  margin: 0;
}
.auth-brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 20px;
  padding: 24px;
}
.auth-panel h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}
.auth-panel p { margin: 0; }
.auth-panel form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.auth-panel label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
}
.auth-panel input[type="email"],
.auth-panel input[type="password"],
.auth-panel input[type="text"] {
  width: 100%;
  border: 1px solid var(--border-md);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
}
.auth-panel input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-dim);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.auth-info {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.auth-hint {
  margin-top: 14px;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--border-md);
  color: var(--text-muted);
  background: var(--surface);
  font-size: 13px;
}
/* Page-level spacing for the sign-in page. Scoped to the body so
   it cannot leak to other pages that happen to load issuepilot.css
   (e.g. the workspace shell). */
body.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-subtitle {
  margin-top: 9px;
  color: var(--text-muted);
}
/* Vertical rhythm helpers for elements inside .auth-panel. Compose
   with .auth-error / .auth-info for coloured alert variants. */
.auth-panel .auth-message { margin-top: 16px; }
.auth-panel .auth-field-error { margin-top: 8px; }
.auth-panel .auth-reset-link { margin-top: 14px; }
.auth-panel button[type="submit"],
.auth-panel a.btn.btn-primary {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
}

/* ============================================================
   ISSUEPILOT — CONFIGURATION (superuser admin area)
   Standalone layout with a sticky header (brand + config nav
   dropdown bar) and a page-content shell. Classes that collide
   with template / workspace names (.panel, .shell, .topbar) are
   scoped under .page-content for the config area only.
   ============================================================ */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 60;
}
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
[data-theme="light"] .brand-mark {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}
.brand-copy h1 {
  margin: 0;
  font-size: 15px;
}
.brand-copy p {
  margin: 1px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Config dropdown nav bar */
.config-nav-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 24px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.nav-section { position: relative; }
.nav-section-btn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  padding: 14px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}
.nav-section-btn:hover { color: var(--text); }
.nav-section-btn.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.nav-arrow {
  font-size: 9px;
  opacity: 0.6;
  line-height: 1;
}
.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 12px;
  padding: 6px;
  min-width: 240px;
  z-index: 100;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
[data-theme="dark"] .nav-dropdown {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.nav-dropdown.is-open { display: block; }
.nav-dropdown-item {
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  transition: background 120ms ease, color 120ms ease;
  text-decoration: none;
}
.nav-dropdown-item:hover {
  background: var(--accent-bg);
  color: var(--text);
}
.nav-dropdown-item.is-active {
  background: var(--accent-bg);
  color: var(--accent);
}
.nav-item-icon {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--border-md);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.nav-dropdown-item.is-active .nav-item-icon {
  background: var(--accent-bg);
  color: var(--accent);
}
.nav-item-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.nav-item-body strong {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item-badge {
  min-width: 1.5rem;
  text-align: center;
  background: var(--border-md);
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Page content wrapper (scopes config collisions) */
.page-content {
  padding: 32px 32px;
  position: relative;
  z-index: 1;
}
.config-shell {
  max-width: 1240px;
  margin: 0 auto;
}
.page-content .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  background: transparent;
  border-bottom: none;
  padding: 0;
}
.headline h2 {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2rem);
}
.headline p {
  margin: 6px 0 0;
  color: var(--text-muted);
  max-width: 55rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Config-scoped .panel — elevated surface card (collides with
   template's simpler .panel) */
.page-content .panel {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 20px;
}

/* Hero / content panels */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.hero > .panel { min-width: 0; }
.resource-list-page .hero { margin-bottom: 0; }
.resource-list-page.section-stack { gap: 16px; min-width: 0; }
.resource-list-page .table-wrap table { table-layout: auto; }

.hero-copy,
.hero-meta,
.section-panel,
.form-panel,
.table-panel,
.empty-panel,
.message-list {
  padding: 22px;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.hero-copy h3,
.section-panel h3,
.form-panel h3,
.table-panel h3,
.empty-panel h3 {
  margin: 0;
  font-size: 22px;
}
.hero-copy p,
.section-panel p,
.form-panel p,
.table-panel p,
.empty-panel p,
.meta-note {
  margin: 0;
  color: var(--text-muted);
}
.hero-copy p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Structured reference copy (e.g. helpdesk email templates guide) */
.hero-doc {
  display: grid;
  gap: 22px;
  margin-top: 2px;
}
.form-panel .hero-doc { gap: 17px; }
.hero-doc-section { display: grid; gap: 7px; }
.hero-doc-lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.hero-doc h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.hero-doc p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}
.hero-doc-muted {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}
.hero-doc a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.hero-doc a:hover { color: var(--accent-dim); }
.doc-code-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.doc-code-list li { margin: 0; }
.hero-doc .doc-code-list code,
.hero-doc p code {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 13px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--border-md);
  border: 1px solid var(--border);
  color: var(--accent);
}
.doc-block {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 12px;
  overflow-x: auto;
}
.doc-block code {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Metrics + config cards */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.metric {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border-md);
}
.metric strong {
  display: block;
  font-size: 26px;
  margin-bottom: 4px;
}
.config-card {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border-md);
  background: var(--surface);
  display: grid;
  gap: 14px;
}
.config-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}
.config-card h4 {
  margin: 0 0 3px;
  font-size: 17px;
}
.config-card p {
  margin: 0;
  color: var(--text-muted);
}
.section-stack { display: grid; gap: 16px; }

/* Messages + chips */
.message-list { display: grid; gap: 12px; }
.message {
  border-radius: 16px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  background: var(--accent-bg);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--border-md);
  color: var(--text-muted);
  font-size: 13px;
}
.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--border-md);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.hero-icon,
.card-icon {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-md);
  font-weight: 700;
  color: var(--accent);
}

/* Tables inside config */
.table-wrap {
  overflow-x: auto;
  min-width: 0;
}
.table-wrap table {
  table-layout: fixed;
  width: 100%;
}
.page-content table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrap th:not(:last-child),
.table-wrap td:not(:last-child) {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table-wrap th:last-child,
.table-wrap td:last-child {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}
.page-content th,
.page-content td {
  text-align: left;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.page-content th {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.page-content tr:last-child td { border-bottom: 0; }
.table-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.table-panel-toolbar { margin-bottom: 12px; }
.table-panel-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-section-heading {
  grid-column: 1 / -1;
  padding-top: 6px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}
.form-section-heading h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}
.form-section-heading p { margin: 0; }
.field { display: grid; gap: 7px; }
.field.is-full { grid-column: 1 / -1; }
.field label {
  font-size: 14px;
  font-weight: 600;
}
.field-help,
.field-errors {
  font-size: 13px;
  color: var(--text-muted);
}
.field-errors { color: var(--danger); }
.field-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border-md);
  background: var(--surface-alt);
  color: var(--text);
  padding: 13px 15px;
  font: inherit;
}
.field-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field-textarea { min-height: 8rem; resize: vertical; }
/* Native color picker: full column-width swatch so it aligns with the
   other inputs on the same row, and the field-help text sits cleanly
   underneath instead of beside it. */
.field-input[type="color"] {
  display: block;
  width: 100%;
  height: 48px;
  padding: 4px;
  cursor: pointer;
}
.field-input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field-input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 10px;
}
.field-input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 10px;
}
/* Inline colour preview used in configuration list tables. */
.color-swatch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.color-swatch-chip {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-md);
  flex-shrink: 0;
}
textarea.field-textarea.field-textarea-autoexpand {
  min-height: 11rem;
  max-height: min(70vh, 36rem);
  resize: vertical;
  overflow-y: hidden;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  field-sizing: content;
}
@supports not (field-sizing: content) {
  textarea.field-textarea.field-textarea-autoexpand {
    min-height: 12rem;
  }
}
/* Compact monospace textarea for list-style allow-lists (one token per line). */
textarea.field-textarea.field-textarea-code {
  min-height: 9rem;
  max-height: 22rem;
  resize: vertical;
  overflow-y: auto;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
}
/* The form template cannot detect `Textarea` widgets to add `is-full`;
   bridge that with :has() so monospace list fields span the full form width. */
.form-grid .field:has(textarea.field-textarea-code) {
  grid-column: 1 / -1;
}
/* Short numeric input so a single-digit cap doesn't stretch across the column. */
.field-input.field-input-numeric {
  width: 12ch;
  min-width: 10ch;
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* Wider variant for byte counts where a value can be 8-11 digits. */
.field-input.field-input-numeric.field-input-numeric--wide {
  width: 18ch;
  min-width: 16ch;
}
.field-multiselect { min-height: 12rem; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 3.1rem;
  padding: 12px 15px;
  border-radius: 14px;
  border: 1px solid var(--border-md);
  background: var(--surface-alt);
}
.toggle-input { width: 1.15rem; height: 1.15rem; }

.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}
.actions-row-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.inline-action-form { display: inline; margin: 0; }
.inline-action-form button { margin: 0; }
.subtle-link { color: var(--text-muted); }

.empty-state {
  border: 1px dashed var(--border-md);
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  background: var(--surface-alt);
}

/* Config responsive */
@media (max-width: 768px) {
  .config-nav-bar { flex-wrap: wrap; padding: 0 12px; }
  .app-header { padding: 12px; }
  .page-content { padding: 20px; }
  .hero { grid-template-columns: 1fr; }
  .nav-dropdown { left: auto; right: 0; max-width: calc(100vw - 24px); }
}
@media (max-width: 720px) {
  .form-grid,
  .metrics { grid-template-columns: 1fr; }
  .page-content .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { justify-content: space-between; }
  .page-content th:nth-last-child(-n+1),
  .page-content td:nth-last-child(-n+1) {
    position: sticky;
    right: 0;
    background: var(--surface);
  }
}

/* ============================================================
   ISSUEPILOT — PORTAL (customer-facing)
   Standalone layout — portal pages do not extend workspace/base.
   Simple topbar + centered content shell; reuses .two-pane /
   .list-col / .detail-pane for the ticket browse view.
   ============================================================ */
.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.portal-layout-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.portal-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 10px;
  flex-shrink: 0;
}
.portal-topbar-brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.portal-shell {
  flex: 1;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.portal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.portal-header strong {
  font-size: 14px;
  color: var(--text);
}
.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  font-size: 12px;
}
.portal-shell .messages,
.content .messages {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.portal-shell .messages li,
.content .messages li {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  margin-bottom: 6px;
}
#portal-saved-filters .saved-filter-form-error {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--danger);
}

/* Form controls in the portal shell */
.portal-form-page {
  max-width: 44rem;
}
.portal-shell input.portal-field,
.portal-shell input[type="email"],
.portal-shell input[type="text"],
.portal-shell textarea,
.portal-form-page input.portal-field,
.portal-form-page input[type="email"],
.portal-form-page input[type="text"],
.portal-form-page textarea {
  width: 100%;
  max-width: 22rem;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-md);
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface) !important;
  background-image: none;
  color: var(--text);
  font: inherit;
}
.portal-shell input:focus,
.portal-shell textarea:focus,
.portal-form-page input:focus,
.portal-form-page textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.portal-shell textarea,
.portal-form-page textarea { max-width: none; }
/* Browsers ignore normal background on autofilled fields; force our palette */
[data-theme="light"] .portal-shell input:-webkit-autofill,
[data-theme="light"] .portal-shell input:-webkit-autofill:hover,
[data-theme="light"] .portal-shell input:-webkit-autofill:focus,
[data-theme="light"] .portal-shell input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
  box-shadow: 0 0 0 1000px #ffffff inset;
  -webkit-text-fill-color: #1e293b;
  caret-color: #1e293b;
}
[data-theme="dark"] .portal-shell input:-webkit-autofill,
[data-theme="dark"] .portal-shell input:-webkit-autofill:hover,
[data-theme="dark"] .portal-shell input:-webkit-autofill:focus,
[data-theme="dark"] .portal-shell input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #0f172a inset;
  box-shadow: 0 0 0 1000px #0f172a inset;
  -webkit-text-fill-color: #e2e8f0;
  caret-color: #e2e8f0;
}

.portal-btn-primary {
  padding: 7px 14px;
  border-radius: 5px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
}
.portal-btn-primary:hover { filter: brightness(1.05); }

/* ============================================================
   ISSUEPILOT — WORK ITEM METADATA DRAWERS
   Right-side slide-over panels for labels / milestone pickers.
   Triggered from the detail meta strip; parent x-data holds the
   labelsOpen / milestoneOpen flags.
   ============================================================ */
.workitem-meta-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.25);
}
.workitem-meta-drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 100%);
  max-width: 100vw;
  z-index: 96;
  background: var(--surface);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
[data-theme="dark"] .workitem-meta-drawer-panel {
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.45);
}
.workitem-meta-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1.25rem;
}
.workitem-meta-drawer-footer {
  flex-shrink: 0;
  display: flex;
  gap: 0.65rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   ISSUEPILOT — WORK ITEM DETAIL CHIPS
   Pill-shaped chips shown above the description body: status,
   priority, assignee, project status — plus label/milestone.
   Each is clickable to open a dropdown (see _editable_badge.html).
   ============================================================ */
.workitem-chip-accent {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
}
.workitem-chip-neutral {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--border-md);
  color: var(--text-muted);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
}
.workitem-chip-assignee-empty {
  color: var(--text-muted);
}
.workitem-chip-assignee-set {
  color: var(--text);
}
.workitem-chip-inline {
  font: inherit;
  font-weight: 500;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
  border: none;
  background: transparent;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.workitem-chip-popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 6px;
  padding: 6px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .workitem-chip-popover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* Label chips (border-color + color set inline from label.color) */
.workitem-label-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-weight: 500;
  font-size: 11px;
  white-space: nowrap;
}

/* Dashed-ghost "Edit labels" / "Edit milestone" trigger */
.workitem-meta-edit-btn {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
}
.workitem-meta-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   ISSUEPILOT — WORK ITEM COMMENTS
   Thread of individual comment cards plus the add-comment form.
   Private comments get a tinted background.
   ============================================================ */
.comment-section-title {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.comment-card {
  margin-bottom: 12px;
  padding: 10px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border-md);
}
.comment-card--private {
  background: var(--accent-bg);
  border-color: var(--accent-dim);
}
.comment-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.comment-author {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.comment-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}
.comment-internal-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--warning);
  color: var(--surface-alt);
  font-weight: 600;
}
.comment-timestamp {
  font-size: 10px;
  color: var(--text-faint);
}
.comment-body {
  font-size: 12px;
  line-height: 1.55;
}
.comment-empty {
  color: var(--text-muted);
  font-size: 12px;
}

.workitem-body-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.35;
  color: var(--text);
}
.workitem-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 20px;
}

.comment-form {
  margin-top: 14px;
}
.comment-form-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
/* ProseMirror editor mount — used wherever a data-issuepilot-pm <div>
   hosts the rich-text editor (new/edit work item, create drawer,
   comment box, portal ticket description, portal ticket reply). */
.pm-editor-mount {
  width: 100%;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface-alt);
  margin-bottom: 5px;
}
.pm-editor-mount--narrow {
  max-width: 32rem;
}

/* Editable badge wrapper. Used by _editable_badge.html — the click
   trigger for inline status / priority / assignee edits. Inline
   modifier is used inside list-row meta text so the trigger flows
   with surrounding copy. */
.editable-badge {
  position: relative;
}
.editable-badge--inline {
  display: inline;
  vertical-align: baseline;
}

/* Tighter padding + gap for label chips that carry a remove button. */
.workitem-label-chip--removable {
  gap: 2px;
  padding: 3px 4px 3px 9px;
}

/* Label chip remove button — the "×" inside a .workitem-label-chip.
   Needs a colour-inherit transparent background so the chip's
   dynamic label.color bleeds through. */
.label-chip-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
.label-chip-remove-btn:hover,
.label-chip-remove-btn:focus-visible {
  opacity: 1;
}
.label-chip-remove-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

/* Configuration-scoped chip accent variant. Plain .chip is a neutral
   pill; .chip--accent paints it with the accent palette. */
.chip--accent {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Static (non-clickable) variant of .workitem-chip-accent. Used by
   the milestone chip in _workitem_metadata_strip.html. */
.workitem-chip-accent--static {
  cursor: default;
  padding: 3px 9px;
  font-size: 11px;
}

/* OAuth mailbox banner (configuration/resource_form.html). Draws a
   subtle panel around the Microsoft OAuth connect controls. */
.oauth-mailbox-banner {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--border-md);
}
.comment-form-submit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.comment-form-internal-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.comment-form-error {
  color: var(--danger);
  font-size: 11px;
  margin: 0 0 6px;
}

/* ============================================================
   ISSUEPILOT — NEW WORK ITEM CREATE DRAWER
   Right-side slide-over form for creating a work item from list
   / queue / project views.
   ============================================================ */
.workitem-create-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 420px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  border-left: 1px solid var(--border);
  z-index: 100;
  padding: 20px;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
}
[data-theme="dark"] .workitem-create-drawer {
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.45);
}
.workitem-create-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.workitem-create-drawer-title {
  font-size: 14px;
  margin: 0;
  color: var(--text);
  font-weight: 600;
}
.workitem-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}
.workitem-drawer-close:hover { color: var(--accent); }

/* ============================================================
   ISSUEPILOT — WORK ITEM EDIT PANEL
   Full-page form used by /workitem/<ref>/edit/.
   ============================================================ */
.workitem-edit {
  max-width: min(60rem, 100%);
  width: 100%;
}
.workitem-edit-panel {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 1rem;
  padding: 1.5rem 1.5rem 1.75rem;
}
.workitem-edit h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
}
.workitem-edit form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
.workitem-edit form select,
.workitem-edit form textarea {
  width: 100%;
  max-width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}
.workitem-edit form input:focus,
.workitem-edit form select:focus,
.workitem-edit form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.workitem-edit form ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.workitem-edit form ul li { margin-bottom: 5px; }
.workitem-edit-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Board flyout header (X button / ref) on the board detail flyout */
.board-flyout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.board-flyout-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   ISSUEPILOT — LIST COLUMN (Work Items + Queue)
   Shared filter form + row anatomy + pagination for the two-pane
   list views. Both templates render the same structure; only the
   URLs, pluralization, and a couple of optional pills differ.
   ============================================================ */
.list-col-filters {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.list-col-project-toggle {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.list-col-project-toggle a {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
}
.list-col-project-toggle a.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.list-col-header-simple {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-chip-active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 8px 2px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.filter-chip-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  font-size: 14px;
}
.filter-clear {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
}
.filter-clear:hover { color: var(--accent); }

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-search {
  flex: 1 1 180px;
  min-width: 180px;
  padding: 6px 10px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.filter-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-line-shell {
  position: relative;
  flex: 2 1 280px;
  min-width: 240px;
}
.filter-line-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.filter-line-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.filter-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border-md);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .filter-suggestions {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.filter-suggestion {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.filter-suggestion code {
  color: var(--text-muted);
  font-size: 11px;
}
.filter-suggestion:hover,
.filter-suggestion.is-active {
  background: var(--accent-bg);
  color: var(--accent);
}
.filter-line-error {
  flex: 1 0 100%;
  color: var(--danger);
  font-size: 11px;
}

.filter-more {
  position: relative;
}
.filter-more-trigger {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface);
}
.filter-more-trigger::-webkit-details-marker { display: none; }
.filter-more-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 280px;
  max-width: 360px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border-md);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .filter-more-popover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.filter-picker-group {
  display: grid;
  gap: 4px;
}
.filter-picker-group + .filter-picker-group {
  margin-top: 12px;
}
.filter-picker-group strong {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.filter-picker-label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.filter-popover-apply {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.filter-per-page {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.filter-per-page select {
  padding: 6px 8px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.filter-apply-btn {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}
.filter-primary-btn {
  font-size: 12px;
  padding: 5px 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.saved-filter-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 140;
  min-width: 220px;
  padding: 10px;
  border: 1px solid var(--border-md);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .saved-filter-menu-panel {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.saved-filter-menu-panel form {
  display: grid;
  gap: 8px;
}
.saved-filter-menu-panel form + form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.saved-filter-menu-panel label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.saved-filter-menu-panel input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-md);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.saved-filter-form-error {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--danger);
}

/* List-row anatomy */
.list-row-link {
  display: block;
  padding: 10px 16px 4px;
  text-decoration: none;
  color: var(--text);
}
.list-row-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.list-row-title {
  font-weight: 500;
  font-size: 13px;
}
.list-row-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.list-row-pills {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.list-row-ref {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 10px;
  color: var(--text-muted);
}
.list-row-pill {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
}
.list-row-pill-status {
  background: var(--accent-bg);
  color: var(--accent);
}
.list-row-pill-priority {
  background: var(--border-md);
  color: var(--text-muted);
}
.list-row-pill-label {
  border: 1px solid;
  /* border-color and color set inline from label.color */
}
.list-row-meta {
  display: flex;
  align-items: baseline;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 16px 10px;
  line-height: 1.4;
}
.list-row-meta-main {
  min-width: 0;
  flex: 1 1 auto;
}
.list-row-source-label {
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.3;
}
.list-row-source-label--helpdesk {
  color: #22d3ee;
  background: color-mix(in srgb, #22d3ee 18%, transparent);
}
.list-row-source-label--project {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
[data-theme="light"] .list-row-source-label--helpdesk {
  background: color-mix(in srgb, #22d3ee 14%, white);
}
[data-theme="light"] .list-row-source-label--project {
  background: color-mix(in srgb, var(--accent) 14%, white);
}
.list-row-meta-sep {
  color: var(--border);
  margin: 0 6px;
}
.list-col-empty {
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Pagination */
.pager {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.pager .pg-btn {
  padding: 3px 9px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.pager .pg-btn:hover { border-color: var(--accent); }
.pager .pg-current {
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}
.pager .pg-disabled {
  padding: 3px 9px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  color: var(--text-faint);
  font-size: 11px;
}
.pager .pg-ellipsis {
  padding: 3px 4px;
  color: var(--text-faint);
  font-size: 11px;
}

/* ============================================================
   ISSUEPILOT — PROJECT LIST ROWS
   Simple stack of .panel-row entries linking to each project.
   ============================================================ */
.project-list {
  max-width: 800px;
}
.project-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 6px;
  margin-bottom: 6px;
  transition: border-color 0.15s;
}
.project-row:hover {
  border-color: var(--accent);
}
.project-row-name {
  color: var(--text);
  text-decoration: none;
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}
.project-row-key {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 10px;
  color: var(--text-faint);
  margin-left: 8px;
}
.project-row-board {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 12px;
}
.project-row-board:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   ISSUEPILOT — WORK ITEM META BAR
   Horizontal strip above the detail body with id / status /
   priority / assignee chips; sits on panel surface.
   ============================================================ */
.workitem-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 6px;
}
.workitem-requester-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--border-md);
  color: var(--text);
  font-size: 11px;
  line-height: 1.3;
}
.workitem-requester-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workitem-requester-chip .workitem-meta-dot {
  color: var(--text-faint);
  overflow: visible;
}
.workitem-cc-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -8px 0 14px;
  font-size: 11px;
}
.workitem-cc-label {
  color: var(--text-faint);
  font-weight: 600;
}
.workitem-cc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--border-md);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
}
.workitem-cc-email {
  color: var(--text-faint);
}

/* ============================================================
   ISSUEPILOT — EDITABLE BADGE DROPDOWN
   Replaces native <select> for inline status / priority edits so
   the first click reveals options.
   ============================================================ */
.editable-badge-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 16rem;
  overflow-y: auto;
}
.editable-badge-menu-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.editable-badge-menu-btn:hover {
  background: var(--accent-bg);
}
.editable-badge-menu-btn.is-current {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   ISSUEPILOT — CREATE DRAWER FORM
   Slide-over drawer for new work items; normalizes control
   styling inside the drawer.
   ============================================================ */
.create-drawer input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
.create-drawer select,
.create-drawer textarea {
  width: 100%;
  max-width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}
.create-drawer input:focus,
.create-drawer select:focus,
.create-drawer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* (Responsive shell collapse superseded by the consolidated
   RESPONSIVE (MOBILE / TABLET) section at the end of this file.) */

/* ============================================================
   ISSUEPILOT — DASHBOARD STAT-TILE GRID
   Four-column grid of linkable stat-tiles on the workspace
   dashboard. Configuration dashboard reuses bare .card-grid.
   ============================================================ */
.stat-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
a.stat-tile {
  color: inherit;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s;
}
a.stat-tile:hover {
  border-color: var(--accent);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

/* ============================================================
   ISSUEPILOT — KANBAN BOARD
   Equal-width columns with fixed-height cards (4-line title
   clamp) plus a move menu and drag handle alongside each card.
   SortableJS targets .board-col-list; keep that selector stable.
   Detail flyout is a right-side slide-over on the same page.
   ============================================================ */
.board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  align-items: stretch;
  height: calc(100vh - 110px);
  padding-bottom: 1rem;
}
.board-col {
  flex: 1 1 0;
  min-width: 260px;
  max-width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border-md);
  border-radius: 0.6rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-col-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.board-col-list {
  flex: 1;
  min-height: 2.5rem;
  min-width: 0;
}
.board-col-list:empty::after {
  content: "Empty";
  font-size: 0.82rem;
  color: var(--text-faint);
  display: block;
  padding: 0.5rem 0;
}

.board-card-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
}
.board-card-wrap:hover { border-color: var(--accent); }

.board-card-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  padding: 0.35rem 0 0.35rem 0.35rem;
}
.board-card-move-menu { position: relative; }
.board-card-move-trigger {
  cursor: pointer;
  list-style: none;
  font-size: 0.72rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border-md);
  border-radius: 0.35rem;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 500;
  font-family: inherit;
}
.board-card-move-trigger::-webkit-details-marker { display: none; }
.board-card-move-trigger:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.board-card-move-options {
  position: absolute;
  left: 0;
  top: calc(100% + 0.25rem);
  min-width: 10rem;
  max-width: min(18rem, 70vw);
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border-md);
  border-radius: 0.4rem;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  z-index: 30;
}
[data-theme="dark"] .board-card-move-options {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.board-card-move-submit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
  margin: 0;
  border: none;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}
.board-card-move-submit:hover,
.board-card-move-submit:focus {
  background: var(--accent-bg);
  color: var(--accent);
  outline: none;
}

.board-card-drag {
  cursor: grab;
  flex: 0 0 auto;
  padding: 0.45rem 0.2rem 0.45rem 0.45rem;
  color: var(--text-faint);
  user-select: none;
  line-height: 1;
  touch-action: none;
  align-self: flex-start;
}
.board-card-drag:active { cursor: grabbing; }

/* Fixed card body: 4 title lines + reference row */
.board-card {
  flex: 1;
  min-width: 0;
  border: none;
  margin: 0;
  padding: 0.6rem 0.75rem 0.6rem 0;
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: calc(0.6rem + 4 * 1.35 * 0.88rem + 0.35rem + 1.15rem + 0.6rem);
  overflow: hidden;
}
.board-card-title {
  font-weight: 500;
  flex: 1 1 auto;
  min-height: calc(4 * 1.35 * 0.88rem);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  line-clamp: 4;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.board-card-ref {
  flex-shrink: 0;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

/* Detail flyout (fragment root replaces #board-detail-flyout) */
.board-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(0, 0, 0, 0.45);
  display: none;
}
.board-detail-backdrop.is-open { display: block; }
[data-theme="light"] .board-detail-backdrop { background: rgba(22, 34, 55, 0.35); }

.board-detail-flyout-mount {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(840px, 100vw);
  max-width: 100%;
  z-index: 86;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  display: none;
}
[data-theme="dark"] .board-detail-flyout-mount {
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.45);
}
.board-detail-flyout-mount.is-open { display: flex; }
.board-detail-flyout-mount .workitem-detail-shell { max-width: none; }
.board-detail-flyout-mount .detail-pane-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Board page: list/board view toggle pills */
.board-view-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.board-view-toggle a {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border-md);
  border-radius: 0.4rem;
  text-decoration: none;
  color: var(--text);
}
.board-view-toggle a.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   PRIORITY DOTS (left of ticket reference)
   Colours come from admin-editable CSS custom properties set by
   apps/appearance/context_processors.py. Hex fallbacks match the
   seeded defaults so fresh installs without migrations still render.
   ============================================================ */
.pdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.p-blocker  { background: #ef4444; }
.p-critical { background: var(--priority-urgent-color, #f97316); }
.p-high     { background: var(--priority-high-color,   #fbbf24); }
.p-medium   { background: var(--priority-medium-color, #a78bfa); }
.p-low      { background: var(--priority-low-color,    #94a3b8); }
.p-none     { background: transparent; border: 1px solid #334155; }

/* ============================================================
   LIFECYCLE STATUS CHIPS
   A single admin-chosen hex per state drives both the foreground and
   a tinted background via color-mix(). Applied to list-row pills, the
   detail-pane editable badge (.workitem-chip-accent), and as a
   standalone .status-chip (e.g. customer portal detail header).
   ============================================================ */
.status-chip {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-chip--new,
.list-row-pill-status.status-chip--new,
.workitem-chip-accent.status-chip--new {
  color: var(--status-new-color, #818cf8);
  background: color-mix(in srgb, var(--status-new-color, #818cf8) 18%, transparent);
  border-color: transparent;
}
.status-chip--open,
.list-row-pill-status.status-chip--open,
.workitem-chip-accent.status-chip--open {
  color: var(--status-open-color, #a78bfa);
  background: color-mix(in srgb, var(--status-open-color, #a78bfa) 18%, transparent);
  border-color: transparent;
}
.status-chip--pending,
.list-row-pill-status.status-chip--pending,
.workitem-chip-accent.status-chip--pending {
  color: var(--status-pending-color, #22d3ee);
  background: color-mix(in srgb, var(--status-pending-color, #22d3ee) 18%, transparent);
  border-color: transparent;
}
.status-chip--resolved,
.list-row-pill-status.status-chip--resolved,
.workitem-chip-accent.status-chip--resolved {
  color: var(--status-resolved-color, #4ade80);
  background: color-mix(in srgb, var(--status-resolved-color, #4ade80) 18%, transparent);
  border-color: transparent;
}
.status-chip--closed,
.list-row-pill-status.status-chip--closed,
.workitem-chip-accent.status-chip--closed {
  color: var(--status-closed-color, #475569);
  background: color-mix(in srgb, var(--status-closed-color, #475569) 22%, transparent);
  border-color: transparent;
}

/* Light theme: use the same admin hex but mix with white for a softer tint. */
[data-theme="light"] .status-chip--new,
[data-theme="light"] .list-row-pill-status.status-chip--new,
[data-theme="light"] .workitem-chip-accent.status-chip--new {
  background: color-mix(in srgb, var(--status-new-color, #818cf8) 14%, white);
}
[data-theme="light"] .status-chip--open,
[data-theme="light"] .list-row-pill-status.status-chip--open,
[data-theme="light"] .workitem-chip-accent.status-chip--open {
  background: color-mix(in srgb, var(--status-open-color, #a78bfa) 14%, white);
}
[data-theme="light"] .status-chip--pending,
[data-theme="light"] .list-row-pill-status.status-chip--pending,
[data-theme="light"] .workitem-chip-accent.status-chip--pending {
  background: color-mix(in srgb, var(--status-pending-color, #22d3ee) 14%, white);
}
[data-theme="light"] .status-chip--resolved,
[data-theme="light"] .list-row-pill-status.status-chip--resolved,
[data-theme="light"] .workitem-chip-accent.status-chip--resolved {
  background: color-mix(in srgb, var(--status-resolved-color, #4ade80) 14%, white);
}
[data-theme="light"] .status-chip--closed,
[data-theme="light"] .list-row-pill-status.status-chip--closed,
[data-theme="light"] .workitem-chip-accent.status-chip--closed {
  background: color-mix(in srgb, var(--status-closed-color, #475569) 14%, white);
}

/* ============================================================
   PRIORITY CHIPS
   Same hex family as the .pdot priority dots so chip + dot read as one
   signal. Applied to the list-row priority pill, the detail-pane
   priority chip (.workitem-chip-neutral), and .priority-chip.
   ============================================================ */
.priority-chip--urgent,
.list-row-pill-priority.priority-chip--urgent,
.workitem-chip-neutral.priority-chip--urgent {
  color: var(--priority-urgent-color, #f97316);
  background: color-mix(in srgb, var(--priority-urgent-color, #f97316) 18%, transparent);
  border-color: transparent;
}
.priority-chip--high,
.list-row-pill-priority.priority-chip--high,
.workitem-chip-neutral.priority-chip--high {
  color: var(--priority-high-color, #fbbf24);
  background: color-mix(in srgb, var(--priority-high-color, #fbbf24) 18%, transparent);
  border-color: transparent;
}
.priority-chip--medium,
.list-row-pill-priority.priority-chip--medium,
.workitem-chip-neutral.priority-chip--medium {
  color: var(--priority-medium-color, #a78bfa);
  background: color-mix(in srgb, var(--priority-medium-color, #a78bfa) 18%, transparent);
  border-color: transparent;
}
.priority-chip--low,
.list-row-pill-priority.priority-chip--low,
.workitem-chip-neutral.priority-chip--low {
  color: var(--priority-low-color, #94a3b8);
  background: color-mix(in srgb, var(--priority-low-color, #94a3b8) 22%, transparent);
  border-color: transparent;
}

[data-theme="light"] .priority-chip--urgent,
[data-theme="light"] .list-row-pill-priority.priority-chip--urgent,
[data-theme="light"] .workitem-chip-neutral.priority-chip--urgent {
  background: color-mix(in srgb, var(--priority-urgent-color, #f97316) 14%, white);
}
[data-theme="light"] .priority-chip--high,
[data-theme="light"] .list-row-pill-priority.priority-chip--high,
[data-theme="light"] .workitem-chip-neutral.priority-chip--high {
  background: color-mix(in srgb, var(--priority-high-color, #fbbf24) 14%, white);
}
[data-theme="light"] .priority-chip--medium,
[data-theme="light"] .list-row-pill-priority.priority-chip--medium,
[data-theme="light"] .workitem-chip-neutral.priority-chip--medium {
  background: color-mix(in srgb, var(--priority-medium-color, #a78bfa) 14%, white);
}
[data-theme="light"] .priority-chip--low,
[data-theme="light"] .list-row-pill-priority.priority-chip--low,
[data-theme="light"] .workitem-chip-neutral.priority-chip--low {
  background: color-mix(in srgb, var(--priority-low-color, #94a3b8) 14%, white);
}

/* Attachment list (ticket description + comments) */
.ip-attachment-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 16px;
}
.ip-attachment-list-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.ip-attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface, transparent);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.2;
  max-width: 100%;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.ip-attachment-item:hover,
.ip-attachment-item:focus-visible {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-color: color-mix(in srgb, var(--text) 18%, var(--border));
}
.ip-attachment-icon {
  display: inline-flex;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.ip-attachment-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ip-attachment-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
  flex: 0 0 auto;
}
.ip-attachment-type {
  font-family: var(--font-mono, ui-monospace, monospace);
}
.pm-doc-readonly .ip-attachment-fig,
.pm-doc-readonly .ip-attachment-image {
  margin: 8px 0;
}
.pm-doc-readonly .ip-attachment-fig img,
.pm-doc-readonly .ip-attachment-image img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ============================================================
   ISSUEPILOT — RESPONSIVE (MOBILE / TABLET)
   Single breakpoint at 1024px. Below it ("compact mode") the
   sidebar becomes an off-canvas drawer and the two-pane
   master/detail collapses to a single full-width column.
   Desktop (>=1024px) is unchanged. Supersedes the old
   max-width:720px shell-collapse block.
   ============================================================ */

/* Drawer chrome is desktop-hidden by default. */
.nav-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1023.98px) {
  /* ---- Hamburger trigger ----------------------------------- */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    margin-right: 2px;
    border: 1px solid var(--border-md);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }
  .nav-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  /* ---- Off-canvas sidebar ---------------------------------- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    max-width: 85vw;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    box-shadow: 2px 0 24px rgba(15, 23, 42, 0.18);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }
  body.nav-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  /* Lock the background scroller while the drawer is open. */
  body.nav-open { overflow: hidden; }
  body.nav-open .content { overflow: hidden; }

  /* Keep the topbar breadcrumb from pushing the theme buttons off-screen. */
  .topbar .breadcrumb {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Mobile back-control is desktop-hidden by default. */
.mobile-back { display: none; }

@media (max-width: 1023.98px) {
  /* ---- Two-pane collapses to a single full-width column ----- */
  .two-pane {
    display: block;
    height: auto;
    overflow: visible;
  }
  .two-pane-list-wrap,
  .list-col {
    height: auto;
    overflow: visible;
  }
  .list-col {
    border-right: none;
  }
  .list-col-scroll {
    overflow: visible;
  }
  .two-pane > .detail-pane {
    height: auto;
    overflow: visible;
    padding: 16px;
  }

  /* List shown by default; the empty detail placeholder is hidden. */
  .two-pane > .detail-pane { display: none; }
  /* When an item is loaded, swap: hide the list, show the detail. */
  .two-pane:has(> .detail-pane[data-workitem-ref]) .two-pane-list-wrap {
    display: none;
  }
  .two-pane:has(> .detail-pane[data-workitem-ref]) > .detail-pane {
    display: flex;
  }

  /* ---- Mobile Back control --------------------------------- */
  .mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 12px;
    padding: 6px 10px;
    border: 1px solid var(--border-md);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    width: fit-content;
  }
  .mobile-back:hover { border-color: var(--accent); color: var(--accent); }
}

/* Disclosure button is desktop-hidden; the advanced wrapper is layout-
   transparent on desktop so the controls keep their existing flex behavior. */
.filter-disclosure-btn { display: none; }
.filter-advanced { display: contents; }

@media (max-width: 1023.98px) {
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-search {
    width: 100%;
    min-width: 0;
    flex: none;
  }
  .filter-disclosure-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-md);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
  }
  /* Collapsed until toggled open. */
  .filter-advanced { display: none; }
  .filter-controls.filters-open .filter-advanced {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .filter-advanced .filter-line-shell,
  .filter-advanced .filter-per-page,
  .filter-advanced .filter-apply-btn,
  .filter-advanced .filter-clear {
    width: 100%;
    min-width: 0;
    /* Reset desktop flex-basis (e.g. .filter-line-shell's 280px), which would
       otherwise inflate height now that the bar is a flex column. */
    flex: none;
  }
  .filter-advanced .filter-per-page {
    justify-content: space-between;
  }
}

@media (max-width: 1023.98px) {
  /* ---- Create drawer fits small screens -------------------- */
  .workitem-create-drawer { width: min(420px, 100%); }

  /* ---- Detail meta wraps without overflow ------------------ */
  .workitem-meta-bar { gap: 6px; }
  .detail-pane .pm-editor-mount,
  .detail-pane .comment-card,
  .detail-pane .comment-body { max-width: 100%; }
  .detail-pane .comment-body pre { overflow-x: auto; }
}

/* ============================================================
   Small-phone fine-tuning (<=480px): tighter padding/type.
   ============================================================ */
@media (max-width: 480px) {
  .content { padding: 14px; }
  .two-pane--flush { margin: -14px; }
  .topbar { padding: 8px 12px; }
  .two-pane > .detail-pane { padding: 14px; }
  .list-row-title { font-size: 13px; }
  .theme-btn { padding: 3px 8px; }
}


/* Live-sync "Updated · refresh" pill (shown on the open detail pane while mid-edit).
   Uses the accent-chip pattern (accent-bg + accent text) so it stays readable and
   theme-correct in both light and dark. */
.live-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  cursor: pointer;
}
.live-sync-pill:hover { border-color: var(--accent); }
.live-sync-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
