/* SDLC dashboard — dark theme (aligned with mockups) */
:root {
  --bg-root: #0a0b14;
  --bg-sidebar: #050614;
  --bg-main: #0a0b1e;
  --bg-card: #121430;
  --bg-card-hover: #16183a;
  --border-subtle: rgba(124, 131, 253, 0.12);
  --accent: #5850ec;
  --accent-hover: #6d66f0;
  --accent-muted: rgba(88, 80, 236, 0.25);
  --text: #f4f4f5;
  --text-muted: #9ca3af;
  --text-dim: #71717a;
  --badge-warn-bg: #3c2a1e;
  --badge-warn-text: #f97316;
  --tab-active-bg: rgba(124, 131, 253, 0.18);
  --tab-active-text: #c7d2fe;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 240px;
  --shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.55);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-brand: "Playfair Display", Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg-root);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars are hidden app-wide for a cleaner, distraction-free surface.
   Scrolling itself stays fully functional (wheel, trackpad, touch, keyboard,
   and programmatic scrollIntoView); only the visual scrollbar chrome is
   removed. Firefox uses ``scrollbar-width: none``; IE/legacy Edge uses
   ``-ms-overflow-style: none``; Chromium/WebKit uses the pseudo-element. */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-corner {
  background: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ----- Sidebar ----- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100%;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.sidebar-toggle-btn,
.sidebar-expand-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-toggle-btn:hover,
.sidebar-expand-btn:hover {
  color: var(--text);
  background: rgba(124, 131, 253, 0.12);
  border-color: rgba(124, 131, 253, 0.35);
}

/* Overlay — must not take flow space or #view-project height:100% overflows. */
.sidebar-expand-btn {
  position: absolute;
  top: 32px;
  left: 40px;
  z-index: 6;
  margin: 0;
}

.sidebar-expand-btn[hidden] {
  display: none !important;
}

/* Keep title/content clear of the expand control when the rail is hidden. */
body.is-sidebar-collapsed .main {
  padding-left: calc(40px + 34px + 14px);
}

body.is-sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0;
  padding: 0;
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

body.is-sidebar-collapsed .sidebar-resize-handle {
  display: none;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  z-index: 5;
  transition: background 0.15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle:focus-visible,
.sidebar-resize-handle.is-dragging {
  background: rgba(124, 131, 253, 0.35);
  outline: none;
}

body.is-resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-sidebar * {
  pointer-events: none;
}

body.is-resizing-sidebar .sidebar-resize-handle {
  pointer-events: auto;
}

.sidebar > nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -8px;
  padding: 0 8px;
  scrollbar-width: none;
}

.sidebar > nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}

.logo:hover {
  opacity: 0.92;
}

.logo:focus-visible {
  outline: 2px solid rgba(124, 131, 253, 0.55);
  outline-offset: 4px;
  border-radius: 6px;
}

.logo-mark {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
}

.logo-wordmark {
  min-width: 0;
  font-family: var(--font-brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-dash {
  color: #f8fafc;
}

.logo-scribe {
  color: #a78bfa;
}

.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-left: 12px;
}

.nav-list,
.nav-sublist {
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.nav-list > li,
.nav-sublist > li {
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.nav-list {
  gap: 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-sublist {
  gap: 2px;
  margin-top: 4px;
  position: relative;
}

.nav-sublist::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.nav-crumb-item.hidden {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-arrow {
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
}

.nav-item-sub {
  margin-left: 14px;
  width: calc(100% - 14px);
  padding: 8px 12px 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
}

.nav-item-sub-deep {
  margin-left: 28px;
  width: calc(100% - 28px);
}

.nav-item-sub .nav-item-arrow {
  font-size: 0.85rem;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.is-active {
  color: var(--text);
  background: rgba(79, 70, 229, 0.22);
}

/* ----- Main ----- */
.main {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100vh;
  background: linear-gradient(165deg, #0c0e22 0%, var(--bg-main) 45%, #080910 100%);
  padding: 32px 40px 48px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ----- App shell: the project view fills the viewport so pages never push
   the whole window into a scroll. Long panels scroll inside their own card,
   and view-local headers stay put. This keeps the surface fixed-height and
   lets dynamic areas (like the assistant chat) own their scrolling. ----- */
#view-project:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#view-project:not(.hidden) > .project-header {
  flex-shrink: 0;
}

#view-project .panel.is-active {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.main-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.main-sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Compact ``.btn`` variant for inline contexts (e.g. the Modify editor's
   Cancel / Save row sitting just below a textarea). Keeps the full ``.btn``
   theming, only trims padding + font size so the buttons don't overpower
   the editor. */
.btn.btn-sm {
  padding: 7px 14px;
  font-size: 0.8125rem;
  border-radius: 8px;
}

/* Inline circular spinner for ``.btn.is-loading``. Inherits ``currentColor``
   so it adapts to whichever button variant it's placed inside (primary,
   ghost, danger, etc.). */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btn-spinner-rotate 0.8s linear infinite;
}

@keyframes btn-spinner-rotate {
  to { transform: rotate(360deg); }
}

.btn.is-loading {
  cursor: progress;
}

/* While the modal is mid-request we visually soften the body so users
   understand input is on hold. The textarea is also flipped to
   ``readonly`` in JS, which is what actually blocks edits. The class
   lives on the ``.overlay`` (matches how the JS toggles it). */
.overlay.is-busy .modal-body {
  opacity: 0.6;
  pointer-events: none;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(124, 131, 253, 0.12);
  border-color: rgba(124, 131, 253, 0.45);
  color: var(--text);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Themed native selects (sidebar org, org panel, modals) */
.sdlc-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 11px 36px 11px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%237c7f93' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.sdlc-select:hover:not(:disabled) {
  border-color: rgba(124, 131, 253, 0.45);
  background-color: rgba(124, 131, 253, 0.06);
}

.sdlc-select:focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.15);
}

.sdlc-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sdlc-select option {
  background: #1a1d2e;
  color: var(--text);
}

.field select.sdlc-select {
  margin-top: 0;
}

.sidebar-switchers {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sidebar-switchers:has(.ux-select.is-open) {
  z-index: 60;
}

.sidebar-org-select .ux-select-trigger,
.sidebar-space-select .ux-select-trigger {
  min-height: 40px;
  padding: 9px 10px 9px 12px;
  font-size: 0.84rem;
}

.sidebar-space-select {
  margin-left: 10px;
}

.sidebar-space-select .ux-select-trigger {
  min-height: 36px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sidebar-org-select .ux-select-menu,
.sidebar-space-select .ux-select-menu {
  min-width: 100%;
  max-width: min(280px, calc(var(--sidebar-w) - 24px));
  /* Keep footer actions pinned; only the option list scrolls. */
  max-height: min(360px, 70vh);
  overflow: hidden;
}

.sidebar-org-select .ux-select-menu-options,
.sidebar-space-select .ux-select-menu-options {
  max-height: 200px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-account-divider.hidden {
  display: none;
}

.sidebar-org-select.is-disabled .ux-select-trigger,
.sidebar-space-select.is-disabled .ux-select-trigger {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.ux-select-menu-search {
  display: block;
  width: calc(100% - 16px);
  margin: 8px 8px 4px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
}

.ux-select-menu-search:focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.45);
}

.ux-select-menu-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding: 6px 4px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ux-select-menu-action {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.ux-select-menu-action:hover,
.ux-select-menu-action:focus-visible {
  background: rgba(124, 131, 253, 0.12);
  color: var(--text);
  outline: none;
}

.nav-divider {
  height: 1px;
  margin: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.field select:not(.sdlc-select) {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
}

.field select:not(.sdlc-select):focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.5);
  box-shadow: 0 0 0 3px rgba(88, 80, 236, 0.18);
}

.btn-danger {
  background: rgba(185, 28, 28, 0.95);
  color: #fff;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ----- Context grid ----- */
.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.context-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  min-width: 0;
  overflow: hidden;
}

.context-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(124, 131, 253, 0.28);
  transform: translateY(-2px);
}

.context-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-width: 0;
}

.context-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.context-card-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 1;
  transform: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.context-card:hover .context-card-delete,
.context-card-delete:focus-visible {
  opacity: 1;
  transform: none;
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.context-card-delete:hover {
  color: #fecaca;
  background: rgba(185, 28, 28, 0.2);
  border-color: rgba(248, 113, 113, 0.45);
}

.context-card-delete svg {
  display: block;
}

.context-card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.badge-warn {
  background: var(--badge-warn-bg);
  color: var(--badge-warn-text);
}

.context-card-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.context-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.context-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s, border-color 0.2s;
  min-width: 0;
  overflow: hidden;
}

.context-stat.is-on {
  background: var(--stat-bg, rgba(124, 131, 253, 0.12));
  border-color: var(--stat-border, rgba(124, 131, 253, 0.28));
}

.context-stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--stat-fg, var(--text));
  background: var(--stat-icon-bg, rgba(255, 255, 255, 0.04));
  transition: background 0.2s, color 0.2s;
  overflow: hidden;
  flex-shrink: 0;
}

.context-stat-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  display: block;
}

.context-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.context-stat.is-on .context-stat-value {
  color: var(--stat-fg, var(--text));
}

.context-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 600;
  line-height: 1.25;
  max-width: 100%;
  word-break: break-word;
}

/* Per-stage colour tokens applied via data-stage on .context-stat */
.context-stat[data-stage="uploaded"] {
  --stat-fg: #7dd3fc;
  --stat-bg: rgba(56, 189, 248, 0.1);
  --stat-border: rgba(56, 189, 248, 0.28);
  --stat-icon-bg: rgba(56, 189, 248, 0.18);
}

.context-stat[data-stage="parsed"] {
  --stat-fg: #fbbf24;
  --stat-bg: rgba(245, 158, 11, 0.1);
  --stat-border: rgba(245, 158, 11, 0.28);
  --stat-icon-bg: rgba(245, 158, 11, 0.18);
}

.context-stat[data-stage="completed"] {
  --stat-fg: #4ade80;
  --stat-bg: rgba(34, 197, 94, 0.1);
  --stat-border: rgba(34, 197, 94, 0.28);
  --stat-icon-bg: rgba(34, 197, 94, 0.18);
}

.empty-hint {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

/* ----- Connector tiles (live inside the Sources panel) ----- */
.detail-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.sources-view-only-hint {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(124, 131, 253, 0.08);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.connector-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  appearance: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.connector-card:hover:not(.is-disabled) {
  background: var(--bg-card-hover);
  border-color: rgba(124, 131, 253, 0.4);
  transform: translateY(-2px);
}

.connector-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.connector-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.connector-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.connector-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
}

.connector-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(124, 131, 253, 0.18);
  flex-shrink: 0;
  overflow: hidden;
}

.connector-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  display: block;
}

/* Brand-coloured chip backgrounds. ``local_file`` is the default tile;
   the legacy ``upload`` / ``document`` aliases are kept so older cached
   responses still paint until the backend backfill runs. */
.connector-card[data-connector="local_file"] .connector-icon,
.connector-card[data-connector="upload"] .connector-icon,
.connector-card[data-connector="document"] .connector-icon {
  background: linear-gradient(135deg, var(--accent), #8b87f3);
}
.connector-card[data-connector="jira"] .connector-icon { background: #2684ff; }
.connector-card[data-connector="confluence"] .connector-icon { background: #1868db; }
.connector-card[data-connector="git"] .connector-icon { background: #f05133; }

.connector-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}

.connector-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.connector-tag {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

.connector-tag.is-available {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.connector-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--tab-active-text);
}

.connector-cta svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
  transition: transform 0.15s ease;
}

.connector-card:hover:not(.is-disabled) .connector-cta svg {
  transform: translateX(2px);
}

.connector-cta-soon {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ----- Modal ----- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 14, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-bottom));
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(165deg, #171a32 0%, #121421 42%, #0c0d16 100%);
  border: 1px solid rgba(124, 131, 253, 0.22);
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-modal), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  overflow: hidden;
}

.overlay.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal.modal-regenerate {
  max-width: 560px;
}

.modal.modal-context {
  max-width: 460px;
}

.modal.modal-jira-clarify {
  max-width: min(720px, 94vw);
  width: 100%;
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}

.modal.modal-jira-clarify .modal-header {
  flex: 0 0 auto;
}

.modal.modal-jira-clarify .modal-subtitle {
  max-width: none;
}

.modal.modal-jira-clarify .jira-clarify-body {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: none;
  padding: 16px 28px 8px;
}

.modal.modal-jira-clarify .modal-actions {
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.modal.modal-jira-clarify .jira-clarify-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.jira-clarify-error {
  flex: 1 1 220px;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #fecaca;
}

.jira-clarify-error.hidden {
  display: none;
}

.modal.modal-source-preview {
  max-width: min(1080px, 95vw);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.source-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.source-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.source-preview-actions .btn {
  font-size: 0.8125rem;
  padding: 8px 14px;
}

.modal-body.source-preview-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 24px;
  min-height: 0;
}

.source-preview-status {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 32px;
  text-align: center;
  line-height: 1.55;
}

.source-preview-status.error {
  color: #ffb3b3;
}

.source-preview-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 60vh;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #1a1f2b;
}

.source-preview-image {
  flex: 0 0 auto;
  align-self: center;
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1f2b;
}

.source-preview-text {
  flex: 1 1 auto;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #1a1f2b;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
}

.source-preview-audio {
  flex: 0 0 auto;
  align-self: center;
  width: min(640px, 100%);
  margin: auto 0;
}

.source-preview-video {
  flex: 0 0 auto;
  align-self: center;
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.source-preview-markdown {
  flex: 1 1 auto;
  padding: 18px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #141828;
  color: var(--text);
  overflow: auto;
  max-height: 70vh;
  line-height: 1.6;
}

.source-preview-markdown h1,
.source-preview-markdown h2,
.source-preview-markdown h3 {
  margin: 1.2em 0 0.6em;
  line-height: 1.3;
}

.source-preview-markdown h1:first-child,
.source-preview-markdown h2:first-child {
  margin-top: 0;
}

.source-preview-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.source-preview-markdown th,
.source-preview-markdown td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
}

.source-preview-markdown th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.source-preview-markdown .source-preview-section + .source-preview-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.source-preview-truncation-note {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.source-preview-fallback {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.source-preview-fallback-icon {
  color: var(--text-dim);
}

.source-preview-fallback-title {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.source-preview-fallback-sub {
  margin: 0;
  font-size: 0.85rem;
  max-width: 480px;
  line-height: 1.55;
}

.source-preview-mode {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.source-preview-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.source-preview-mode-btn:hover {
  color: var(--text);
}

.source-preview-mode-btn.is-active {
  background: rgba(124, 131, 253, 0.22);
  color: var(--tab-active-text);
}

.modal-header {
  padding: 28px 28px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.modal-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text);
}

.modal-subtitle {
  margin: 12px 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 52ch;
}

.delete-category-em {
  color: var(--text);
  font-weight: 600;
}

.modal-subtext-danger {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 113, 113, 0.08);
  border: 1px solid rgba(255, 113, 113, 0.32);
  color: #ffb3b3;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.modal-subtext {
  margin: 14px 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 52ch;
}

.modal-delete {
  border-color: rgba(248, 113, 113, 0.22);
  box-shadow: var(--shadow-modal), 0 0 0 1px rgba(185, 28, 28, 0.12) inset;
}

.modal-body {
  padding: 24px 28px 4px;
}

.modal-body .field:last-child {
  margin-bottom: 0;
}

.field {
  margin-bottom: 24px;
}

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.field input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
}

.field input:not([type="checkbox"]):not([type="radio"])::placeholder {
  color: var(--text-dim);
}

.field input:not([type="checkbox"]):not([type="radio"]):focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.5);
  box-shadow: 0 0 0 3px rgba(88, 80, 236, 0.18);
}

.field-hint {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.member-suggest-field {
  position: relative;
}

.member-suggest-list {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 6px;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #17171c;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.member-suggest-list.hidden {
  display: none;
}

.member-suggest-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
}

.member-suggest-item:hover,
.member-suggest-item.is-active {
  background: rgba(124, 131, 253, 0.16);
}

.member-suggest-item .muted {
  display: block;
  font-size: 0.75rem;
}

.llm-provider-field {
  border: 0;
  padding: 0;
  margin: 0 0 24px;
}

.llm-provider-field legend {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0;
}

.llm-provider-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.llm-provider-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.llm-provider-option:has(input:checked) {
  border-color: rgba(124, 131, 253, 0.55);
  background: rgba(88, 80, 236, 0.18);
}

.llm-provider-option input {
  margin: 0;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px rgb(11, 12, 29) inset !important;
  box-shadow: 0 0 0 1000px rgb(11, 12, 29) inset !important;
  background-color: rgb(11, 12, 29) !important;
  background-image: none !important;
  transition: background-color 9999s ease-in-out 0s !important;
}

.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgb(11, 12, 29) inset,
    0 0 0 3px rgba(88, 80, 236, 0.18) !important;
  box-shadow: 0 0 0 1000px rgb(11, 12, 29) inset,
    0 0 0 3px rgba(88, 80, 236, 0.18) !important;
}

.field textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
  resize: vertical;
}

.field textarea:focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.45);
  box-shadow: 0 0 0 3px rgba(88, 80, 236, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 28px 28px;
  margin: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.2);
}

.modal-actions-split {
  justify-content: space-between;
}

.modal-actions-buttons {
  display: flex;
  gap: 8px;
}

.modal-actions .btn {
  min-height: 42px;
  padding-left: 20px;
  padding-right: 20px;
  font-size: 0.9rem;
}

.modal-actions .btn-primary {
  min-width: 148px;
}

.modal-actions .btn-danger {
  min-width: 148px;
}

/* ----- Context detail ----- */
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.detail-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.16);
}

.tab.is-active {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  border-color: rgba(124, 131, 253, 0.35);
}

.panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  min-height: 280px;
}

.panel.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* When a panel stacks multiple sections (e.g. Sources has both
   "Connectors" and "Ingested Source Items"), every subsequent
   ``.panel-head`` needs breathing room above it so the two sections
   read as distinct cards instead of one continuous block. The
   general-sibling selector targets the second-and-later head in any
   panel without touching panels that only have one. */
.panel-head ~ .panel-head {
  margin-top: 36px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.local-file-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex-wrap: wrap;
}

.file-dropzone {
  position: relative;
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 2px dashed rgba(124, 131, 253, 0.22);
  background: rgba(124, 131, 253, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.file-dropzone:hover {
  border-color: rgba(124, 131, 253, 0.55);
  background: rgba(124, 131, 253, 0.08);
}

.file-dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(124, 131, 253, 0.14);
  transform: scale(1.005);
}

.file-dropzone.has-file {
  border-style: solid;
  border-color: rgba(124, 131, 253, 0.45);
  background: rgba(124, 131, 253, 0.1);
}

.file-dropzone-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tab-active-text);
  background: rgba(124, 131, 253, 0.2);
  flex-shrink: 0;
}

.file-dropzone-icon svg {
  display: block;
}

.file-dropzone-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.file-dropzone-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-dropzone-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-dropzone-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.file-dropzone-clear:hover {
  background: rgba(185, 28, 28, 0.15);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.3);
}

.file-dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.hint {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.local-file-hint {
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.local-file-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.format-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.local-file-hint-text {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.status-line {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-line.is-busy {
  color: var(--tab-active-text);
}

.status-line.error {
  color: #f87171;
}

.status-line.ok {
  color: #86efac;
}

/* ----- Outputs (markdown) ----- */
.output-shell {
  display: flex;
  flex-direction: column;
  min-height: min(380px, 52vh);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#output-panes {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: min(320px, 50vh);
}

.output-pane-shell {
  display: none;
  flex-direction: column;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.output-pane-shell.is-active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.output-pane-shell.is-approved {
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.45);
  border-radius: var(--radius-md);
}

.output-pane-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.output-pane-toolbar .index-status-chip {
  max-width: min(100%, 240px);
}

/* ---------------------------------------------------------------------------
   Version picker

   Sits above the output toolbar inside Review Center *only* when the
   asset has at least one ``knowledge_entry_revisions`` row (initial-only
   extractions don't get a picker). Uses the same ``.ux-select`` custom
   dropdown as the feedback "Reason" field so a long change-history
   collapses into one trigger button + scrollable menu instead of a
   wrapping pill row.

   ``is-historical-view`` is added to the surrounding ``.output-pane-shell``
   when the user picks a non-Current version; it greys the toolbar
   buttons that would otherwise mutate the live row and tints the
   markdown body so the snapshot reads as clearly different from live.
   --------------------------------------------------------------------------- */
.version-picker {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(124, 131, 253, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.version-picker-label {
  flex: 0 0 auto;
  font-size: 0.66rem;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ux-select-version {
  flex: 0 1 auto;
  width: 100%;
  max-width: 360px;
}

/* The version trigger shows a two-line "Current / Modified 5m ago" label
   compressed into one row. The default ``.ux-select-trigger`` styling
   already handles the chevron + focus ring; nothing extra needed. */

.ux-select-version .ux-select-option-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  white-space: normal;
  line-height: 1.25;
}

.version-menu-title {
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.005em;
}

.version-menu-sub {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
}

.ux-select-version .ux-select-option.is-selected .version-menu-sub {
  color: rgba(230, 233, 255, 0.78);
}

.version-sub-sep,
.version-trigger-sep {
  opacity: 0.55;
  margin: 0 1px;
}

/* Auto-refreshing "Xm ago" spans (see ``_startLiveTimeTicker``).
   ``tabular-nums`` keeps the column width stable as the number flips
   from "9m" -> "10m" so the surrounding label doesn't reflow on every
   tick. */
.live-time {
  font-variant-numeric: tabular-nums;
}

.output-pane-shell.is-historical-view .output-pane-toolbar {
  background: rgba(124, 131, 253, 0.06);
}

.output-pane-shell.is-historical-view .output-pane-view::before {
  content: "Read-only snapshot";
  display: inline-block;
  margin: 0 0 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(124, 131, 253, 0.16);
  border: 1px solid rgba(124, 131, 253, 0.32);
  color: #e6e9ff;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.output-pane-shell.is-historical-view .btn-toolbar[data-history-disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.output-pane-shell.is-archived-view .output-pane-toolbar {
  background: rgba(248, 113, 113, 0.06);
}

.output-pane-shell.is-archived-view .btn-toolbar[data-archived-disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.output-pane-shell.is-archived-view .btn-feedback {
  opacity: 0.4;
  pointer-events: none;
}

.output-pane-shell.is-archived-view .feedback-inline {
  opacity: 0.55;
  pointer-events: none;
}

.output-pane-deleted-state {
  margin: 24px auto;
  max-width: 520px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  border: 1px dashed rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.05);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
}

.output-pane-deleted-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
}

.output-pane-deleted-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.output-pane-deleted-sub {
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
  max-width: 440px;
}

.output-pane-toolbar .btn-toolbar {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.output-pane-toolbar .btn-toolbar:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.output-pane-toolbar .btn-toolbar.btn-approve.is-on {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.12);
}

.output-pane-toolbar .btn-toolbar:disabled {
  opacity: 0.6;
  cursor: wait;
}

.toolbar-divider {
  align-self: stretch;
  width: 1px;
  min-height: 24px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.12);
}

.output-pane-toolbar .btn-toolbar.btn-feedback.is-on,
.output-pane-toolbar .btn-toolbar.btn-feedback.is-pending {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.52);
  background: rgba(34, 197, 94, 0.12);
}

.output-pane-toolbar .btn-toolbar.btn-feedback-down.is-on,
.output-pane-toolbar .btn-toolbar.btn-feedback-down.is-pending {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
}

/* ``is-pending`` is the transient sibling of ``is-on``: it shows the
   user that opening the form selected this intent, but the row hasn't
   been saved to the database yet. We hint at that with a dashed border
   when it's pending-only (not yet also the saved vote). */
.output-pane-toolbar .btn-toolbar.btn-feedback.is-pending:not(.is-on),
.output-pane-toolbar .btn-toolbar.btn-feedback-down.is-pending:not(.is-on) {
  border-style: dashed;
}

/* Icon-only thumbs buttons. Sit alongside the text ``.btn-toolbar`` set
   inside ``.output-pane-toolbar`` -- same border / hover / focus
   treatment, but a square footprint and no text padding. The SVG
   inherits ``currentColor`` so the green / red ``is-on`` /
   ``is-pending`` rules above keep working unchanged. */
.output-pane-toolbar .btn-toolbar.btn-feedback-icon {
  width: 34px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.output-pane-toolbar .btn-toolbar.btn-feedback-icon svg {
  display: block;
}

.output-pane-toolbar .btn-toolbar.btn-feedback-icon:not(.is-on):not(.is-pending) {
  color: rgba(255, 255, 255, 0.55);
}

.output-pane-toolbar .btn-toolbar.btn-feedback-icon:not(.is-on):not(.is-pending):hover {
  color: var(--text);
}

.feedback-inline {
  display: none;
  flex: 1 0 100%;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
  padding: 14px 16px 16px;
  border: 1px solid rgba(124, 131, 253, 0.22);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(124, 131, 253, 0.06) 0%, rgba(124, 131, 253, 0) 55%),
    rgba(11, 17, 32, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.feedback-inline.is-open {
  display: flex;
}

.feedback-inline-header h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--text);
}

.feedback-inline-header p {
  margin: 4px 0 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.feedback-fields {
  display: grid;
  gap: 12px;
  /* Reason is a compact ~220px column; Comment takes the rest. The
     dropdown popup expands beyond this width on demand via its own
     ``ux-select-menu`` styles, so a narrow trigger doesn't truncate
     the option list. */
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
}

@media (max-width: 760px) {
  .feedback-fields { grid-template-columns: 1fr; }
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.feedback-field-label {
  font-size: 0.66rem;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.feedback-field textarea {
  min-height: 60px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  color: var(--text);
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.4;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.feedback-field textarea::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.feedback-field textarea:focus-visible {
  outline: none;
  border-color: rgba(124, 131, 253, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.18);
  background: rgba(124, 131, 253, 0.04);
}

.feedback-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.output-pane-toolbar .btn-toolbar.btn-feedback-save {
  color: var(--tab-active-text);
  border-color: rgba(124, 131, 253, 0.45);
  background: rgba(124, 131, 253, 0.14);
}

.output-pane-toolbar .btn-toolbar.btn-feedback-save:hover {
  color: var(--tab-active-text);
  background: rgba(124, 131, 253, 0.22);
  border-color: rgba(124, 131, 253, 0.65);
}

/* ---------------------------------------------------------------------------
   Custom listbox ("ux-select")

   Drop-in replacement for ``<select>`` whose popup chrome we couldn't style
   consistently across browsers. Used by the feedback "Reason" picker; designed
   to be reusable wherever we need a styled dropdown that matches the dark
   theme. See ``_toggleUxSelect`` / ``_selectUxOption`` in SdlcApp.js for the
   behaviour.
   --------------------------------------------------------------------------- */
.ux-select {
  position: relative;
  width: 100%;
}

.ux-select.is-disabled .ux-select-trigger {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.ux-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  color: rgba(255, 255, 255, 0.55);
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease,
    color 0.16s ease;
}

.ux-select-trigger:hover {
  border-color: rgba(124, 131, 253, 0.45);
  background: rgba(124, 131, 253, 0.06);
  color: var(--text);
}

.ux-select-trigger:focus-visible {
  outline: none;
  border-color: rgba(124, 131, 253, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.18);
}

.ux-select-trigger.has-value {
  color: var(--text);
}

.ux-select-trigger[aria-expanded="true"] {
  border-color: rgba(124, 131, 253, 0.65);
  background: rgba(124, 131, 253, 0.08);
  box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.14);
}

.ux-select-value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ux-select-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  transition: transform 0.18s ease, color 0.16s ease;
}

.ux-select-trigger:hover .ux-select-chevron,
.ux-select-trigger[aria-expanded="true"] .ux-select-chevron {
  color: var(--text);
}

.ux-select-trigger[aria-expanded="true"] .ux-select-chevron {
  transform: rotate(180deg);
}

.ux-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(13, 18, 33, 0.98);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.48), 0 2px 8px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: ux-select-menu-in 0.12s ease-out;
}

.ux-select-menu[hidden] {
  display: none;
}

@keyframes ux-select-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ux-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.ux-select-option:hover,
.ux-select-option:focus-visible {
  background: rgba(124, 131, 253, 0.16);
  color: var(--text);
  outline: none;
}

.ux-select-option.is-selected {
  background: rgba(124, 131, 253, 0.22);
  color: #e6e9ff;
  font-weight: 500;
}

.ux-select-option-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ux-select-option-tick {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(124, 131, 253, 0.95);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.ux-select-option.is-selected .ux-select-option-tick {
  opacity: 1;
  transform: scale(1);
}

/* Scrollbar hidden inside the menu (scroll still works via wheel/touch). */
.ux-select-menu::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.output-pane-view {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 18px 20px;
  max-height: min(70vh, 720px);
  overflow: auto;
}

.output-pane-edit-wrap {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.output-pane-edit {
  width: 100%;
  min-height: 360px;
  flex: 1 1 auto;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(124, 131, 253, 0.35);
  background: #05060f;
  color: var(--text);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.55;
  resize: vertical;
  tab-size: 2;
}

.output-pane-edit:focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.7);
  box-shadow: 0 0 0 2px rgba(124, 131, 253, 0.18);
}

.output-pane-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Markdown "Modify" editor: formatting toolbar + split (raw | preview). */
.md-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
}

.md-edit-btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    border-color 0.12s ease;
}

.md-edit-btn:hover {
  background: rgba(124, 131, 253, 0.16);
  border-color: rgba(124, 131, 253, 0.45);
  color: var(--text);
}

.md-edit-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.md-edit-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.md-edit-col-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
}

.md-edit-preview {
  min-height: 360px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 900px) {
  .md-edit-split {
    grid-template-columns: 1fr;
  }
}

.output-tabs {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.output-tab {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  max-width: 220px;
  text-align: left;
  line-height: 1.3;
}

.output-tab:hover {
  color: var(--text);
}

.output-tab.is-active {
  color: var(--tab-active-text);
  border-bottom-color: var(--accent);
}

.output-tab.is-active.is-approved {
  border-bottom-color: #22c55e;
}

.output-tab.is-approved {
  color: #86efac;
}

.output-pane {
  display: none;
  max-height: min(62vh, 640px);
  overflow: auto;
  padding: 20px 22px;
}

.output-pane.is-active {
  display: block;
}

.prose {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #e4e4e7;
}

.prose h1,
.prose h2,
.prose h3 {
  color: var(--text);
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  font-weight: 700;
}

.prose h1 {
  font-size: 1.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.35em;
}

.prose h2 {
  font-size: 1.1rem;
}

.prose h3 {
  font-size: 1rem;
}

.prose p {
  margin: 0.65em 0;
}

.prose ul,
.prose ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
}

.prose code {
  font-size: 0.84em;
  background: rgba(88, 80, 236, 0.15);
  padding: 0.15em 0.45em;
  border-radius: 4px;
}

.prose pre {
  background: #05060f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.78rem;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 1em 0;
}

.prose th,
.prose td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  text-align: left;
}

.prose th {
  background: rgba(88, 80, 236, 0.12);
}

.prose hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1.5em 0;
}

.json-block {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: #a1a1aa;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.processing-body {
  min-height: 120px;
}

.processing-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.processing-run {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px 40px;
  gap: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.process-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(124, 131, 253, 0.2);
  border-top-color: var(--accent);
  animation: process-spin 0.85s linear infinite;
}

@keyframes process-spin {
  to {
    transform: rotate(360deg);
  }
}

.process-run-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.process-run-title code {
  font-size: 0.88em;
  color: var(--tab-active-text);
  background: var(--accent-muted);
  padding: 2px 8px;
  border-radius: 6px;
}

.process-run-sub {
  margin: 0;
  max-width: 420px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.process-run-error {
  margin: 0;
  color: #fca5a5;
  font-size: 0.9rem;
  max-width: 520px;
  line-height: 1.5;
}

/* ----- Auth screen ----- */
.view-auth {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 48px) 20px;
  overflow: hidden;
  background: #070812;
}

.auth-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% -10%, rgba(88, 80, 236, 0.28), transparent 55%),
    radial-gradient(ellipse 45% 40% at 85% 85%, rgba(14, 165, 233, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 35% at 10% 80%, rgba(99, 102, 241, 0.1), transparent 45%),
    linear-gradient(180deg, #0b0d1c 0%, #070812 100%);
}

.auth-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
}

.auth-stage::after {
  content: "";
  position: absolute;
  width: min(520px, 70vw);
  height: min(520px, 70vw);
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(88, 80, 236, 0.16), transparent 68%);
  filter: blur(8px);
  animation: auth-glow 8s ease-in-out infinite alternate;
}

@keyframes auth-glow {
  from {
    opacity: 0.55;
    transform: translate(-50%, -50%) scale(0.96);
  }
  to {
    opacity: 0.9;
    transform: translate(-50%, -48%) scale(1.04);
  }
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  animation: auth-enter 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes auth-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-card {
  width: 100%;
  padding: clamp(32px, 5vw, 44px) clamp(28px, 4vw, 40px) 36px;
  border-radius: 20px;
  border: 1px solid rgba(167, 176, 255, 0.14);
  background:
    linear-gradient(165deg, rgba(24, 26, 58, 0.92) 0%, rgba(14, 16, 36, 0.96) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 28px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  text-align: center;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.auth-brand-mark {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.auth-brand-name {
  font-family: var(--font-brand);
  font-size: clamp(2rem, 4.5vw, 2.45rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  color: #f8fafc;
}

.auth-lede {
  margin: 0 auto 28px;
  max-width: 28ch;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.auth-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.auth-form .field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-form input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.auth-error {
  margin: 0 0 14px;
  min-height: 0;
  font-size: 0.85rem;
  color: #fca5a5;
  line-height: 1.4;
}

.auth-error:empty {
  display: none;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-microsoft-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #fff;
  color: #1f1f1f;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.auth-microsoft-btn:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.auth-microsoft-btn:active {
  transform: translateY(0);
}

.auth-microsoft-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(88, 80, 236, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.22);
}

.auth-microsoft-btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.auth-ms-logo {
  display: inline-flex;
  flex-shrink: 0;
}

.auth-footnote {
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}

.auth-toggle {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--tab-active-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-link:hover {
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .auth-shell,
  .auth-stage::after,
  .auth-microsoft-btn {
    animation: none;
    transition: none;
  }
}

/* ----- Sidebar account ----- */
.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  position: relative;
  z-index: 40;
}

.sidebar-account {
  position: relative;
}

.sidebar-account-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-account-trigger:hover,
.sidebar-account.is-open .sidebar-account-trigger {
  background: rgba(124, 131, 253, 0.1);
  border-color: rgba(124, 131, 253, 0.25);
}

.sidebar-account .sidebar-user {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  display: block;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email:empty {
  display: none;
}

.sidebar-account-chevron {
  flex-shrink: 0;
  color: var(--text-dim);
  display: inline-flex;
}

.sidebar-account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #12141f;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 70;
}

.sidebar-account-menu[hidden] {
  display: none;
}

.sidebar-account-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.sidebar-account-item:hover,
.sidebar-account-item:focus-visible {
  background: rgba(124, 131, 253, 0.12);
  color: var(--text);
  outline: none;
}

.sidebar-account-item-muted {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.sidebar-account-divider {
  height: 1px;
  margin: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-account-item.hidden {
  display: none;
}

/* =========================================================================
   Enterprise data model UI (Source > Source Item > Knowledge Asset)
   -------------------------------------------------------------------------
   Styles for the per-project sub-nav, six right-hand panels, metrics
   tiles, source-item / knowledge-asset tables, and the read-only
   Knowledge Base detail view. All scoped under `.view-project` so they
   never leak into the auth or top-level Projects landing.
   ========================================================================= */

/* Per-space tool nav (Overview, Assistant, Requirements, …) */
.nav-subnav {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-subnav.hidden {
  display: none;
}

.nav-item.is-disabled,
.nav-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-item-soon {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.nav-item-badge {
  margin-left: auto;
  flex-shrink: 0;
  /* Neutral default (used for purely informational counts on
     Sources, Knowledge Base, etc.). Modifier classes below switch the
     palette to ``warn`` (red, for the Review Center pending pile) or
     ``ok`` (green, e.g. approved counts). */
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  white-space: nowrap;
}

.nav-item-badge.is-warn {
  background: rgba(248, 113, 113, 0.22);
  color: #fecaca;
}

.nav-item-badge.is-ok {
  background: rgba(74, 222, 128, 0.18);
  color: #bbf7d0;
}

/* The active sub-nav row uses a tinted highlight; lift the badge
   contrast so the number stays readable on top of it. */
.nav-item.is-active .nav-item-badge {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.nav-item.is-active .nav-item-badge.is-warn {
  background: rgba(248, 113, 113, 0.32);
  color: #fff1f1;
}

.nav-item.is-active .nav-item-badge.is-ok {
  background: rgba(74, 222, 128, 0.28);
  color: #ecfccb;
}

.nav-item-badge:empty {
  display: none;
}

/* Project header (banner above the 6 panels) */
.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.project-header-eyebrow {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.project-header-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 6px 0 4px;
}

.project-header-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.project-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Workspace: metrics blocks */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metrics-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.metrics-title {
  margin: 0 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  background: rgba(124, 131, 253, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-card.metric-warn {
  background: rgba(248, 113, 113, 0.06);
  border-color: rgba(248, 113, 113, 0.18);
}

.metric-card.metric-pending {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.22);
}

.metric-card.metric-ok {
  background: rgba(74, 222, 128, 0.07);
  border-color: rgba(74, 222, 128, 0.22);
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Data tables (Workspace + Sources) */
.data-table-wrap {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(124, 131, 253, 0.06);
  vertical-align: middle;
  color: var(--text);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(124, 131, 253, 0.06);
}

.data-table tbody tr.is-flash {
  animation: row-flash 1.6s ease-out;
}

@keyframes row-flash {
  0% { background: rgba(245, 197, 24, 0.32); }
  60% { background: rgba(245, 197, 24, 0.18); }
  100% { background: transparent; }
}

/* Loading placeholders used by SWR panel renderers when the project
   has no cached data yet (Workspace / Sources tables, Review Center /
   Knowledge Base lists). Replaced by real rows once the background
   fetch resolves. */
.data-table tbody tr.table-loading-row td {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 24px 16px;
  border-bottom: none;
}

.asset-list-loading {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 24px 16px;
}

.data-table .col-name {
  font-weight: 500;
}

.data-table .col-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.data-table .col-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .col-name-action {
  flex-shrink: 0;
  border: 1px solid rgba(124, 131, 253, 0.32);
  background: rgba(124, 131, 253, 0.1);
  color: var(--tab-active-text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.data-table .col-name-action:hover {
  background: rgba(124, 131, 253, 0.22);
  color: var(--text);
  border-color: rgba(124, 131, 253, 0.55);
}

.data-table .col-name-action:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* Retry variant uses the warning palette so the destructive-ish
   reset-and-rerun affordance reads distinctly from the neutral
   "Preview" action. Amber instead of red because retry is not an
   error -- it's a corrective action. */
.data-table .col-name-action-retry {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
}

.data-table .col-name-action-retry:hover {
  background: rgba(251, 191, 36, 0.22);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.65);
}

.data-table .col-name-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* When the sub-line is an ingestion error, mute the colour toward red
   so the row clearly reads as failed even before the user looks at
   the status pill. Truncate with ellipsis -- the full envelope sits
   on the ``title`` tooltip. */
.data-table .col-name-sub.col-name-error {
  color: #fca5a5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* One pill colour per derived Source Item bucket, matching the published flow:
   Queued → Parsing → Classifying → Generating Knowledge → Review Pending
   → Approved (Knowledge Base). The pill `status-*` class is the bucket
   returned by `statusPillBucket(...)` in SdlcApp.js -- not the raw DB
   status -- so the colours stay aligned with the human-facing flow. */
.status-pill.status-queue {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

.status-pill.status-parsing {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

.status-pill.status-classification {
  background: rgba(124, 131, 253, 0.18);
  color: #c4b5fd;
}

.status-pill.status-generating {
  background: rgba(244, 114, 182, 0.16);
  color: #f9a8d4;
}

.status-pill.status-review {
  background: rgba(251, 191, 36, 0.18);
  color: #fcd34d;
}

.status-pill.status-failed {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}

.status-pill.status-archived {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}

.status-pill.status-approved {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
}

.index-status-chip {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 6px 8px;
  max-width: min(100%, 280px);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  background: rgba(96, 165, 250, 0.14);
  color: #93c5fd;
  line-height: 1.25;
  white-space: normal;
  box-sizing: border-box;
}

.index-status-chip.is-index-queued {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.index-status-chip.is-indexing {
  background: rgba(96, 165, 250, 0.18);
  color: #bfdbfe;
}

.index-status-chip.is-index-failed {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}

.index-status-chip.is-indexed,
.index-status-chip.is-approved {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
}

.index-status-retry {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.index-status-retry:hover {
  color: #fff;
}

/* Local file card (inline expansion of the "Local file" connector) */
.local-file-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-top: 18px;
  margin-bottom: 28px;
}

.local-file-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.local-file-card-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.local-file-card-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Fireflies transcript picker */
.fireflies-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.fireflies-search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.fireflies-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.fireflies-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
}

.fireflies-search-input:focus {
  outline: none;
  border-color: rgba(38, 132, 255, 0.55);
}

.fireflies-filter-select {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.fireflies-filter-select:focus {
  outline: none;
  border-color: rgba(38, 132, 255, 0.55);
}

.fireflies-list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 2px 0;
}

.confluence-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 10px 2px 0;
}

.confluence-options .btn {
  margin-left: auto;
}

.fireflies-selectall {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.fireflies-empty {
  margin: 6px 2px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fireflies-transcript-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  margin: 10px 0 14px;
}

.fireflies-transcript-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.fireflies-transcript-row:hover {
  border-color: rgba(38, 132, 255, 0.45);
}

.fireflies-transcript-row.is-imported {
  opacity: 0.55;
  cursor: default;
}

.fireflies-transcript-check {
  margin-top: 3px;
  flex: 0 0 auto;
}

.fireflies-transcript-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fireflies-transcript-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong, var(--text));
}

.fireflies-transcript-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-line.status-error {
  color: var(--danger, #d64545);
}

.status-line.status-ok {
  color: var(--success, #2e9e6b);
}

/* Jira workspace — full-height SaaS surface, not a nested card.
   Outer scroll stays on the workspace so the draft tree is never
   squeezed into a few leftover flex pixels under the compose bar. */
#view-project #panel-requirements.is-active {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
  background: transparent;
  border: 0;
}

.jira-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #0d0e1c;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.jira-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 3;
  background: #0d0e1c;
}

.jira-workspace-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.jira-workspace-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #93c5fd;
  background: rgba(38, 132, 255, 0.14);
  border: 1px solid rgba(38, 132, 255, 0.32);
}

.jira-workspace-head-actions {
  flex-shrink: 0;
}

.jira-empty {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  margin: 0 auto;
  padding: 48px 28px;
  max-width: 32rem;
  color: var(--text-muted);
  text-wrap: pretty;
}

.jira-workspace:has(#jira-disconnected-actions:not(.hidden)) .jira-empty {
  display: flex;
}

.jira-workspace:has(#jira-disconnected-actions:not(.hidden)) .jira-generation-section {
  display: none;
}

.jira-empty h4 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text);
  font-weight: 650;
}

.jira-empty p {
  margin: 0;
  line-height: 1.55;
  font-size: 0.9rem;
}

.jira-empty-mark {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: #93c5fd;
  background: rgba(38, 132, 255, 0.12);
  border: 1px solid rgba(38, 132, 255, 0.28);
  margin-bottom: 4px;
}

.jira-connector-card-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 650;
}

.jira-connector-card-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.jira-connector-connected {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.jira-workspace:has(.jira-generation-section:not(.hidden)) .jira-connector-connected {
  flex: 0 0 auto;
  overflow: visible;
}

.jira-setup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.015);
}

.jira-setup-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.jira-setup-site {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.jira-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.jira-project-key-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex: 1 1 360px;
  min-width: 220px;
}

.jira-project-key-field input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-hover);
  color: var(--text);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.jira-board-url-field input {
  width: 100%;
}

.jira-target-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.jira-connected-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jira-compose {
  padding: 18px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jira-workspace:has(.jira-generation-section:not(.hidden)) .jira-compose {
  padding: 12px 22px 10px;
}

.jira-workspace:has(.jira-generation-section:not(.hidden)) .jira-compose-box textarea {
  min-height: 4.5rem;
  height: auto;
  max-height: 8rem;
  overflow-y: auto;
}

.jira-workspace:has(.jira-generation-section:not(.hidden)) .jira-compose-foot {
  justify-content: flex-end;
}

.jira-workspace:has(.jira-generation-section:not(.hidden)) .jira-generation-help {
  display: none;
}

.jira-compose-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jira-compose-box {
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: #14162a;
  padding: 12px 14px;
}

.jira-compose-box textarea {
  width: 100%;
  min-height: 88px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
  resize: vertical;
}

.jira-compose-box textarea:focus {
  outline: none;
}

.jira-compose-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .jira-compose-foot,
  .jira-setup-bar,
  .jira-generation-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .jira-setup-actions {
    margin-left: 0;
    width: 100%;
  }

  .jira-project-key-field,
  .jira-setup-identity,
  .jira-setup-actions {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
  }

  .assistant-row {
    width: min(64rem, calc(100% - 20px));
  }

  .jira-generation-section,
  .jira-issue-tree {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
  }
}

.jira-generation-section {
  margin: 8px 22px 16px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  /* Size to the draft tree; scroll the workspace — never squash cards. */
  overflow: visible;
  flex: 0 0 auto;
  min-height: min(520px, 62vh);
  display: flex;
  flex-direction: column;
}

.jira-generation-section.is-loading {
  opacity: 0.82;
}

.jira-generate-dropdown {
  position: relative;
  display: inline-block;
}

#btn-jira-generate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.jira-asset-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  margin-left: 2px;
  transition: transform 0.15s ease;
}

.jira-generate-dropdown.is-open .jira-asset-caret {
  transform: rotate(180deg);
}

.jira-generate-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 380px;
  max-width: min(380px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-modal);
}

.jira-generate-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.jira-generate-menu-head > span {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jira-generate-menu-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.jira-asset-picker-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.jira-asset-picker-count {
  font-size: 0.82rem;
  color: var(--text);
}

.jira-asset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.jira-asset-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.jira-asset-item:hover {
  border-color: rgba(38, 132, 255, 0.45);
}

.jira-asset-item.is-selected {
  border-color: rgba(38, 132, 255, 0.6);
  background: rgba(38, 132, 255, 0.08);
}

.jira-asset-check {
  margin-top: 2px;
  flex-shrink: 0;
}

.jira-asset-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.jira-asset-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.jira-asset-item-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.jira-asset-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 6px 2px;
}

.jira-asset-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.jira-generation-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.jira-generation-prompt label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jira-generation-prompt textarea {
  width: 100%;
  min-height: 78px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text);
  resize: vertical;
}

.jira-generation-help {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-dim);
  max-width: 44rem;
}

.jira-generation-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(8, 9, 20, 0.45);
  flex-shrink: 0;
}

.jira-generation-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.jira-select-all-wrap,
.jira-regen-children-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.jira-tree-push-select {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
}

.jira-clarify-q {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.jira-clarify-q.is-invalid .jira-clarify-text {
  border-color: rgba(248, 113, 113, 0.75);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}

.jira-clarify-q.is-invalid .jira-clarify-prompt {
  color: #fecaca;
}

.jira-clarify-q:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.jira-clarify-q > .jira-clarify-prompt {
  display: block;
  margin-bottom: 10px;
  line-height: 1.5;
}

.jira-clarify-q .jira-clarify-text {
  min-height: 88px;
  width: 100%;
}

.jira-clarify-unknown {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.jira-clarify-unknown input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: #7c83fd;
  cursor: pointer;
  border-radius: 4px;
}

.jira-clarify-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 8px;
  font-size: 0.8125rem;
}

.jira-clarify-modes label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.jira-clarify-lookin {
  margin-top: 8px;
  width: 100%;
  min-height: 40px;
}

.jira-regen-children-wrap {
  margin-top: 10px;
}

.jira-generation-toolbar h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.jira-generation-toolbar .status-line {
  margin: 0;
  font-size: 0.78rem;
}

.jira-issue-tree {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 18px;
  /* Grow with cards; parent workspace scrolls. Shrinking this with
     overflow:visible was stacking acceptance-criteria rows on top of
     each other ("chunk" ghost on hover). */
  flex: 0 0 auto;
  min-height: min(420px, 50vh);
  overflow: visible;
}

.jira-tree-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.jira-tree-loading-text {
  flex: 1 1 auto;
}

.jira-tree-loading-sub {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  opacity: 0.75;
}

/* "Context used" panel under a generated run — mirrors the Assistant's
   retrieval panel (reuses .assistant-context-* card styles inside). */
.jira-context-panel {
  margin: 0;
  padding: 0 16px 16px;
}

.jira-scope-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(124, 92, 255, 0.1);
  font-size: 0.82rem;
}

.jira-scope-chip {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.25);
  color: var(--text, #fff);
  white-space: nowrap;
}

.jira-scope-text {
  color: var(--text-muted);
}

.jira-context-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted, rgba(127, 127, 127, 0.06));
  overflow: hidden;
}

.jira-context-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.jira-context-summary::-webkit-details-marker {
  display: none;
}

.jira-context-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s ease;
}

.jira-context-details[open] .jira-context-summary::before {
  transform: rotate(90deg);
}

.jira-context-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 14px 14px;
}

.jira-context-rewrite {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-bottom: 4px;
}

.jira-context-rewrite-exp {
  opacity: 0.8;
}

.jira-tree-skeleton {
  height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.08) 37%,
    rgba(255, 255, 255, 0.03) 63%
  );
  background-size: 400% 100%;
  animation: jira-skeleton-shimmer 1.4s ease infinite;
}

@keyframes jira-skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.jira-tree-item {
  flex-shrink: 0;
  background: #16182c;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
}

.jira-tree-item.is-unsourced {
  border-color: rgba(251, 191, 36, 0.45);
}

.jira-tree-item.is-failed {
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.06);
}

.jira-tree-item.is-pushed {
  border-color: rgba(74, 222, 128, 0.4);
}

.jira-tree-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
  font-size: 0.8rem;
  line-height: 1.4;
}

.jira-error-banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--text);
}

.jira-error-banner-title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fca5a5;
}

.jira-error-banner-msg {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: #fca5a5;
}

.jira-error-banner-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.jira-error-banner-list li {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
}

.jira-error-banner-list li strong {
  color: var(--text);
}

.jira-error-banner-list li span {
  color: var(--text-muted);
}

.jira-tree-group {
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jira-tree-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.jira-tree-group-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--tab-active-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.jira-tree-group-title {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jira-tree-group-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 2px 9px;
}

.jira-tree-group-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jira-tree-node {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Children sit indented under their parent with a connector rail so the
   Epic -> Story -> Sub-task linkage is obvious at a glance. */
.jira-tree-children {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: 14px;
  padding-left: 16px;
  border-left: 2px solid var(--border-subtle);
}

.jira-tree-node.is-collapsed > .jira-tree-children {
  display: none;
}

.jira-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.jira-tree-toggle:disabled {
  cursor: default;
  visibility: hidden;
}

.jira-tree-caret {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--text-muted);
  transition: transform 0.15s ease;
}

/* Expanded by default points down; collapsed points right. */
.jira-tree-node:not(.is-collapsed) > .jira-tree-item .jira-tree-caret {
  transform: rotate(90deg);
}

.jira-tree-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.jira-tree-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(38, 132, 255, 0.2);
  color: #93c5fd;
  flex-shrink: 0;
}

.jira-tree-type.type-epic {
  background: rgba(139, 92, 246, 0.22);
  color: #c4b5fd;
}

.jira-tree-type.type-story {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.jira-tree-type.type-subtask {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

.jira-tree-type.type-bug {
  background: rgba(248, 113, 113, 0.22);
  color: #fca5a5;
}

.jira-tree-childcount {
  flex-shrink: 0;
  min-width: 20px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 1px 7px;
}

.jira-tree-key {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #93c5fd;
}

/* Epics read as the strongest container; deeper levels get a subtle accent. */
.jira-tree-node[data-depth="0"] > .jira-tree-item {
  border-left: 3px solid rgba(139, 92, 246, 0.55);
}

.jira-tree-summary-input {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.jira-tree-desc-wrap {
  position: relative;
  margin-top: 8px;
  /* Keep long descriptions inside the card; don't paint over AC rows. */
  z-index: 0;
}

.jira-tree-desc {
  width: 100%;
  min-height: 96px;
  max-height: 12rem;
  padding: 10px 72px 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: #0c0d18;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
}

.jira-tree-desc-wrap.is-expanded .jira-tree-desc {
  max-height: none;
  overflow-y: hidden;
}

.jira-tree-desc-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  margin: 0;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 20, 33, 0.92);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  cursor: pointer;
}

.jira-tree-desc-toggle:hover {
  color: var(--text);
  border-color: rgba(124, 131, 253, 0.45);
  background: rgba(28, 31, 52, 0.98);
}

.jira-tree-desc-toggle[hidden] {
  display: none;
}

.jira-tree-meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jira-tree-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.jira-tree-item.is-regenerating,
.jira-tree-node.is-regenerating {
  position: relative;
  pointer-events: none;
}

.jira-tree-item.is-regenerating > :not(.jira-regen-overlay),
.jira-tree-node.is-regenerating > :not(.jira-regen-overlay) {
  filter: blur(2px);
  opacity: 0.45;
}

.jira-regen-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--text, #e2e8f0);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.jira-regen-overlay-text {
  max-width: 28rem;
}

/* Story-point pill in the issue head (Stories + Bugs). */
.jira-tree-sp {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

/* Acceptance criteria block under the description (editable, one per line). */
.jira-tree-ac {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.jira-tree-ac-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.jira-tree-ac-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jira-tree-ac-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}

.jira-tree-ac-bullet {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 12px;
  border-radius: 50%;
  background: rgba(124, 131, 253, 0.65);
}

.jira-tree-ac-item {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.35rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
  field-sizing: content;
  white-space: pre-wrap;
  word-break: break-word;
}

.jira-tree-ac-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.jira-tree-ac-remove:hover {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

.jira-tree-ac-add {
  align-self: flex-start;
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}

.jira-tree-ac-add:hover {
  border-color: rgba(124, 131, 253, 0.5);
  color: var(--text);
}

/* Label chips under the description. */
.jira-tree-labels {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jira-tree-label-chip {
  font-size: 0.7rem;
  color: #a5b4fc;
  background: rgba(124, 131, 253, 0.1);
  border: 1px solid rgba(124, 131, 253, 0.28);
  border-radius: 999px;
  padding: 1px 9px;
}

/* Publish options (Sprint + Labels) above the generated tree. */
.jira-publish-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  padding: 10px 16px;
  margin: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  flex-shrink: 0;
}

.jira-publish-options.hidden {
  display: none;
}

.jira-publish-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.jira-publish-field select,
.jira-publish-field input {
  min-width: 180px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-hover);
  color: var(--text);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
}

/* Labels: a searchable dropdown combobox with selected chips above it. */
.jira-publish-labels {
  flex: 1 1 320px;
  min-width: 260px;
}

.jira-label-control {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jira-label-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jira-label-selected.hidden {
  display: none;
}

.jira-label-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: normal;
  color: #c7d2fe;
  background: rgba(124, 131, 253, 0.18);
  border: 1px solid rgba(124, 131, 253, 0.45);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
}

.jira-label-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.jira-label-chip-x:hover {
  background: rgba(248, 113, 113, 0.4);
  color: #fff;
}

.jira-label-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-hover);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.jira-label-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  flex-shrink: 0;
}

.jira-label-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.jira-label-menu.hidden {
  display: none;
}

.jira-label-search {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-hover);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
}

.jira-label-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.jira-label-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.jira-label-option:hover {
  background: var(--bg-card-hover);
}

.jira-label-check {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.jira-label-option.is-selected .jira-label-check {
  background: var(--accent);
  border-color: var(--accent);
}

.jira-label-option.is-selected .jira-label-check::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
}

.jira-label-option-empty {
  padding: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.jira-label-create {
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
  color: #a5b4fc;
  font-family: inherit;
  font-size: 0.82rem;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  padding: 8px;
  cursor: pointer;
}

.jira-label-create:hover {
  color: #c7d2fe;
}

.jira-label-create.hidden {
  display: none;
}

.jira-publish-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* Asset list (Review Center + Knowledge Base) */
.asset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-align: left;
  width: 100%;
  color: inherit;
  font-family: inherit;
}

.asset-row:hover {
  background: var(--bg-card-hover);
  border-color: rgba(124, 131, 253, 0.28);
}

.asset-row.asset-row-archived {
  opacity: 0.78;
}

.asset-row.asset-row-archived .asset-row-preview {
  font-style: italic;
  color: rgba(255, 255, 255, 0.4);
}

.asset-row.asset-row-archived:hover {
  border-color: rgba(248, 113, 113, 0.32);
}

.asset-row-main {
  flex: 1;
  min-width: 0;
}

.asset-row-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.asset-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.asset-row-meta .index-status-chip {
  max-width: min(100%, 220px);
}

.asset-row-preview {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-row-arrow {
  color: var(--text-dim);
  font-size: 1.2rem;
}

/* Asset detail panes (Review Center + Knowledge Base detail) */
.asset-detail {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-top: 16px;
}

.asset-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.asset-detail-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
}

.asset-detail-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.review-collab-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 0.78rem;
  line-height: 1.35;
}

.review-collab-banner.hidden {
  display: none;
}

.review-collab-viewers {
  color: var(--text-muted);
}

.review-collab-lock {
  color: var(--warning, #c98a1a);
  font-weight: 500;
}

.kb-detail-actions,
.review-detail-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.kb-detail-actions [data-index-chip-host],
.review-detail-actions [data-index-chip-host] {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
}

.kb-detail-body {
  padding: 6px 2px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Analytics panel — KPI tiles, pie chart cards, legend, table */
.analytics-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.kpi-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 84px;
  min-width: 0;
}

.kpi-tile-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.kpi-tile-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.kpi-tile-foot {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.kpi-tile.is-accent .kpi-tile-value {
  color: var(--tab-active-text);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 240px;
}

.analytics-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.analytics-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-card-sub {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.analytics-card-body {
  display: flex;
  flex-direction: row;
  gap: 18px;
  align-items: center;
  flex: 1 1 auto;
}

.analytics-card-body.is-empty {
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  min-height: 140px;
}

.analytics-donut {
  flex-shrink: 0;
  width: 150px;
  height: 150px;
  position: relative;
}

.analytics-donut svg {
  width: 100%;
  height: 100%;
  display: block;
}

.analytics-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.analytics-donut-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.analytics-donut-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.analytics-legend {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-legend-row {
  /* ``minmax(0, 1fr)`` is the part that makes the name column actually
     truncate with ellipsis when the meta cell is wide -- with a bare
     ``1fr`` the grid track refuses to shrink below content width. */
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  min-width: 0;
}

.analytics-legend-swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.analytics-legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  cursor: default;
}

.analytics-legend-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: default;
}

.analytics-card-body.is-single {
  align-items: stretch;
  justify-content: flex-start;
  min-height: 140px;
}

.analytics-single-stat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.analytics-single-stat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.analytics-single-stat-name {
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  cursor: default;
}

.analytics-single-stat-value {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.analytics-single-stat-unit {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}

.analytics-single-stat-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.analytics-legend-row.is-total {
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 8px;
  margin-top: 4px;
  color: var(--text-muted);
}

.analytics-table-card .data-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px);
  overflow: auto;
  max-height: 420px;
}

.analytics-table {
  /* Honour the <colgroup> widths instead of letting auto-layout
     stretch numeric columns disproportionately. */
  width: 100%;
  table-layout: fixed;
}

.analytics-table th,
.analytics-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-table td.is-numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.analytics-table .source-item-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.analytics-table .source-item-cell span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.analytics-table .source-item-cell .sub {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* ============================================================
   Analytics v2 — sectioned layout, stage filter,
   per-section stat grids, expandable Source Item breakdown.
   ============================================================ */

/* Compact KPI strip variant used at the top of the new layout.
   Auto-fits more tiles per row because the strip is the universal
   anchor that stays on screen across stage filters. */
.analytics-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
}

.analytics-kpi-grid .kpi-tile {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.025),
    rgba(255, 255, 255, 0.005) 60%
  );
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.analytics-kpi-grid .kpi-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, #7c83fd, transparent);
  opacity: 0.0;
  transition: opacity 0.18s ease;
}

.analytics-kpi-grid .kpi-tile:hover {
  border-color: rgba(124, 131, 253, 0.35);
  transform: translateY(-1px);
}

.analytics-kpi-grid .kpi-tile:hover::before,
.analytics-kpi-grid .kpi-tile.is-accent::before {
  opacity: 1;
}

.analytics-kpi-grid .kpi-tile.is-accent {
  background: linear-gradient(
    180deg,
    rgba(124, 131, 253, 0.10),
    rgba(124, 131, 253, 0.02) 60%
  );
  border-color: rgba(124, 131, 253, 0.30);
}

/* ============================================================
   Space usage tabs — Overview / Knowledge / Assistant / Jira.
   Sub-nav plus the Overview-only mix + trend primitives.
   ============================================================ */

.analytics-tabs {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.analytics-tab-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.analytics-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 7px 14px;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.analytics-tab:hover {
  color: var(--text);
  background: rgba(124, 131, 253, 0.08);
}

.analytics-tab.is-active {
  color: var(--text);
  background: rgba(124, 131, 253, 0.14);
  border-color: rgba(124, 131, 253, 0.35);
}

.analytics-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.analytics-period select {
  min-width: 140px;
}

/* Spend mix: one tile per surface with its share of the bill. */
.usage-mix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.usage-mix-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px);
  background: rgba(255, 255, 255, 0.02);
}

.usage-mix-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.usage-mix-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.usage-mix-value {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.usage-mix-bar,
.usage-trend-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.usage-mix-bar > span,
.usage-trend-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.usage-mix-foot {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Daily trend: date · bar · tokens · cost, one row per day. */
.usage-trend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
}

.usage-trend-row {
  display: grid;
  grid-template-columns: 88px 1fr 64px 72px;
  align-items: center;
  gap: 12px;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.usage-trend-tokens,
.usage-trend-cost {
  text-align: right;
}

.usage-trend-cost {
  color: var(--text);
}

.usage-table {
  /* Usage tables have few, evenly weighted columns -- unlike the
     pipeline drill-down, they carry no <colgroup>. */
  table-layout: auto;
}

.usage-empty {
  margin: 0;
  padding: 18px 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.usage-footnote {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

/* Top toolbar: data filters on the left, summary meta on the right. */
.analytics-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.analytics-filter-controls {
  display: inline-flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.analytics-select {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.analytics-select-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-left: 2px;
}

.analytics-select select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 32px 7px 12px;
  font-size: 0.83rem;
  font-weight: 500;
  font-family: inherit;
  min-width: 160px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%237c7f93' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 8px;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.analytics-select select:hover {
  border-color: rgba(124, 131, 253, 0.45);
}

.analytics-select select:focus {
  outline: none;
  border-color: rgba(124, 131, 253, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.15);
}

.analytics-select select option {
  background: #1a1d2e;
  color: var(--text);
}

.analytics-filter-reset {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  align-self: flex-end;
}

.analytics-filter-reset:hover {
  color: var(--text);
  border-color: rgba(232, 121, 249, 0.45);
  background: rgba(232, 121, 249, 0.06);
}

.analytics-filter-reset[hidden] {
  display: none;
}

.analytics-toolbar-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.analytics-toolbar-meta-item {
  position: relative;
  padding-left: 14px;
  cursor: default;
}

.analytics-toolbar-meta-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(124, 131, 253, 0.55);
  transform: translateY(-50%);
}

/* Section blocks. Each Parsing / Classification / Extraction
   section is a card with a subtle accent strip on the left. */
.analytics-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  overflow: hidden;
}

.analytics-section::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, rgba(124, 131, 253, 0.6), transparent 80%);
  pointer-events: none;
}

.analytics-section[data-stage-section="parsing"]::before {
  background: linear-gradient(180deg, #f59e0b, transparent 80%);
}

.analytics-section[data-stage-section="classification"]::before {
  background: linear-gradient(180deg, #5dd6c5, transparent 80%);
}

.analytics-section[data-stage-section="extraction"]::before {
  background: linear-gradient(180deg, #e879f9, transparent 80%);
}

.analytics-section[data-stage-section="table"]::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 80%);
}

/* Compact source-types card -- single horizontal stacked bar +
   chip legend, replaces the oversized donut-based overview section. */
.analytics-source-types-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.analytics-source-types-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, #7c83fd, transparent 80%);
  pointer-events: none;
}

.analytics-source-types-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.analytics-source-types-total {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  cursor: default;
}

.analytics-source-types-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.analytics-source-types-bar:empty {
  display: none;
}

.analytics-source-types-bar-segment {
  height: 100%;
  display: block;
  transition: filter 0.16s ease;
}

.analytics-source-types-bar-segment:hover {
  filter: brightness(1.15);
}

.analytics-source-types-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.analytics-source-types-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  cursor: default;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.analytics-source-types-chip:hover {
  border-color: rgba(124, 131, 253, 0.32);
  background: rgba(124, 131, 253, 0.05);
}

.analytics-source-types-chip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.analytics-source-types-chip-name {
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-source-types-chip-meta {
  color: var(--text-muted);
}

.analytics-source-types-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.analytics-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analytics-section-title h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.analytics-section-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(124, 131, 253, 0.12);
  color: #b3b7ff;
  border: 1px solid rgba(124, 131, 253, 0.30);
}

.analytics-section-badge.is-parsing {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.32);
}

.analytics-section-badge.is-classification {
  background: rgba(93, 214, 197, 0.10);
  color: #7be0d2;
  border-color: rgba(93, 214, 197, 0.30);
}

.analytics-section-badge.is-extraction {
  background: rgba(232, 121, 249, 0.10);
  color: #f4b8ff;
  border-color: rgba(232, 121, 249, 0.30);
}

.analytics-section-sub {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-muted);
}

.analytics-section-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Per-section stat grids — these are the numerical breakouts
   the user requested for each stage (Parsing Tool / Parse Tier /
   Credits Used / Avg Parsing Time, and the equivalents for
   Classification + Extraction). */
.analytics-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.analytics-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px);
  min-height: 84px;
  transition: border-color 0.16s ease, background 0.16s ease;
  cursor: default;
}

.analytics-stat:hover {
  border-color: rgba(124, 131, 253, 0.30);
  background: rgba(124, 131, 253, 0.04);
}

.analytics-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.analytics-stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: auto;
}

/* Chart card pair inside a section -- 1-up on narrow screens,
   2-up otherwise. */
.analytics-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.analytics-card-row .analytics-card {
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}

/* Standalone donut card living directly under a stat grid (no
   wrapping card-row). Less padding + reduced min-height because
   most projects only render a handful of category buckets. */
.analytics-card-inline {
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
  min-height: 200px;
  padding: 16px 18px 18px;
}

/* Source Item breakdown — table polish + expandable rows. */
.analytics-section-table .analytics-table-card {
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
}

.analytics-section-table .data-table-wrap {
  border: none;
  border-radius: 0;
  max-height: none;
}

.analytics-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-weight: 600;
}

/* Right-align numeric header cells so they sit directly above the
   right-aligned numeric values in the body (otherwise the cell text
   reads centre vs. right and the table looks misaligned). */
.analytics-table thead th.is-numeric {
  text-align: right;
}

.analytics-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.83rem;
  vertical-align: middle;
}

.analytics-table tbody tr.analytics-row:hover {
  background: rgba(124, 131, 253, 0.04);
}

.analytics-table tbody tr.analytics-row.is-expanded {
  background: rgba(124, 131, 253, 0.06);
}

.analytics-table tbody tr.analytics-row.is-expanded td {
  border-bottom-color: transparent;
}

.analytics-table-toggle-col {
  width: 36px;
  max-width: 36px;
  padding-right: 0;
}

.analytics-row-toggle {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  text-decoration: none;
  padding: 0;
  margin: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.18s ease, color 0.16s ease, background 0.16s ease;
}

.analytics-row-toggle:focus {
  outline: none;
}

.analytics-row-toggle:focus-visible {
  outline: 2px solid rgba(124, 131, 253, 0.45);
  outline-offset: 1px;
}

.analytics-row-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.analytics-row-toggle.is-open {
  transform: rotate(90deg);
  color: #b3b7ff;
}

.analytics-row-toggle svg {
  display: block;
  pointer-events: none;
}

.analytics-row-toggle.is-disabled {
  width: 22px;
  height: 22px;
  display: inline-block;
  cursor: default;
  opacity: 0;
  pointer-events: none;
}

.analytics-token-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.analytics-token-sep {
  color: var(--text-muted);
  font-weight: 400;
}

.analytics-row-detail td {
  padding: 0 14px 16px 50px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.015);
}

.analytics-row-detail.hidden {
  display: none;
}

.analytics-row-detail-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.analytics-row-detail-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analytics-row-detail-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.analytics-row-detail-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.analytics-row-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.analytics-row-detail-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analytics-row-detail-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 6px;
}

.analytics-row-detail-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(232, 121, 249, 0.12);
  color: #f4b8ff;
  border: 1px solid rgba(232, 121, 249, 0.28);
  letter-spacing: 0.02em;
  /* Let the chip grow to fit its full label -- the previous
     ``max-width: 180px`` was clipping long category names like
     "FRD — Functional requirements". The card head uses flex so
     the meta column on the right still wraps below cleanly when
     the chip needs the whole row. */
  white-space: nowrap;
}

.analytics-row-detail-card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.analytics-row-detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 12px;
}

.analytics-row-detail-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.analytics-row-detail-stat-wide {
  grid-column: 1 / -1;
}

.analytics-row-detail-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.analytics-row-detail-stat-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Thin, visible scrollbars for reading surfaces (chat + Jira drafts).
   The app hides chrome globally; these panes need a cue that content
   continues below. */
.assistant-transcript,
.assistant-chat-list,
.assistant-prose pre,
.jira-workspace,
.jira-tree-desc,
.jira-issue-tree {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 131, 253, 0.4) transparent;
}

.assistant-transcript::-webkit-scrollbar,
.assistant-chat-list::-webkit-scrollbar,
.assistant-prose pre::-webkit-scrollbar,
.jira-workspace::-webkit-scrollbar,
.jira-tree-desc::-webkit-scrollbar,
.jira-issue-tree::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.assistant-transcript::-webkit-scrollbar-thumb,
.assistant-chat-list::-webkit-scrollbar-thumb,
.assistant-prose pre::-webkit-scrollbar-thumb,
.jira-workspace::-webkit-scrollbar-thumb,
.jira-tree-desc::-webkit-scrollbar-thumb,
.jira-issue-tree::-webkit-scrollbar-thumb {
  background: rgba(124, 131, 253, 0.38);
  border-radius: 999px;
}

/* AI Assistant — header buttons */
.assistant-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}


/* AI Assistant — ChatGPT-like workspace: chats rail + reading column */
#view-project #panel-assistant.is-active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  background: transparent;
  border: 0;
}

#panel-assistant .panel-head {
  flex-shrink: 0;
}

.assistant-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
  background: #0b0c18;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.assistant-chat-nav {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #080910;
  border-right: 1px solid var(--border-subtle);
}

.assistant-chat-nav-head {
  display: flex;
  align-items: center;
  padding: 12px;
  flex-shrink: 0;
}

.assistant-chat-nav-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.assistant-new-chat {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(124, 131, 253, 0.28);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  background: rgba(124, 131, 253, 0.12);
}

.assistant-new-chat:hover {
  background: rgba(124, 131, 253, 0.2);
  border-color: rgba(124, 131, 253, 0.45);
}

.assistant-chat-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.assistant-chat-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 9px 8px 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}

.assistant-chat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.assistant-chat-item:hover {
  background: rgba(124, 131, 253, 0.1);
}

.assistant-chat-item.is-active {
  background: var(--tab-active-bg);
  border-color: rgba(124, 131, 253, 0.22);
}

.assistant-chat-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.assistant-chat-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-chat-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-chat-owner {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

.assistant-chat-delete {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
  opacity: 0;
}

.assistant-chat-delete svg {
  display: block;
  width: 14px;
  height: 14px;
}

.assistant-chat-item:hover .assistant-chat-delete,
.assistant-chat-item:focus-within .assistant-chat-delete,
.assistant-chat-item.is-active .assistant-chat-delete,
.assistant-chat-item.is-confirming .assistant-chat-delete {
  opacity: 1;
}

.assistant-chat-delete:hover,
.assistant-chat-item.is-confirming .assistant-chat-delete {
  color: #f87171;
  background: rgba(220, 38, 38, 0.12);
}

.assistant-chat-pop {
  padding: 8px;
  border-radius: 8px;
  background: #12141f;
  border: 1px solid rgba(248, 113, 113, 0.28);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.assistant-chat-pop-copy {
  margin: 0 0 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.assistant-chat-pop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.assistant-chat-pop-cancel,
.assistant-chat-pop-confirm {
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.assistant-chat-pop-cancel {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.assistant-chat-pop-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
}

.assistant-chat-pop-confirm {
  background: rgba(185, 28, 28, 0.95);
  color: #fff;
}

.assistant-chat-pop-confirm:hover {
  background: #dc2626;
}

.assistant-chat-empty {
  opacity: 0.7;
  font-size: 0.82rem;
  padding: 16px 10px;
  color: var(--text-muted);
}

.assistant-chat-nav-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 12px;
  flex-shrink: 0;
}

.assistant-chat-nav-foot:not(:has(button:not([hidden]))) {
  display: none;
}

.assistant-chat-more {
  width: 100%;
}

.assistant-icon-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #c7d2fe;
  cursor: pointer;
}

.assistant-icon-btn:hover {
  color: #fff;
  background: rgba(124, 131, 253, 0.16);
  border-color: rgba(124, 131, 253, 0.4);
}

.assistant-usage-head-btn {
  width: auto;
  height: 34px;
  gap: 6px;
  padding: 0 10px 0 8px;
}

.assistant-usage-head-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.assistant-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  background: #0d0e1c;
}

.assistant-thread-head {
  flex-shrink: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.assistant-thread-title {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 8px;
  max-width: calc(100% - 120px);
  text-align: left;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 8px;
}

.assistant-thread-title:disabled {
  cursor: default;
  opacity: 0.9;
}

.assistant-thread-title:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.04);
}

.assistant-thread-title-input {
  width: min(420px, 100%);
  border: 1px solid rgba(124, 131, 253, 0.4);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 10px;
}

@media (max-width: 900px) {
  .assistant-layout {
    flex-direction: column;
  }

  .assistant-chat-nav {
    width: 100%;
    max-height: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .assistant-chat-nav-head {
    padding: 0;
    flex-shrink: 0;
  }

  .assistant-new-chat {
    width: auto;
    padding: 8px 12px;
  }

  .assistant-chat-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 8px;
    gap: 6px;
    flex: 1 1 auto;
  }

  .assistant-chat-item {
    min-width: 160px;
    padding: 8px 10px;
  }

  .assistant-chat-meta {
    display: none;
  }

  .assistant-chat-nav-foot {
    display: none;
  }

  .assistant-row.is-user .assistant-bubble {
    max-width: 100%;
  }
}

.assistant-transcript {
  flex: 1 1 auto;
  min-height: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 16px 0 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.assistant-empty {
  margin: auto;
  max-width: 36rem;
  padding: 24px 20px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.assistant-empty-mark {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: #c7d2fe;
  background: rgba(124, 131, 253, 0.14);
  border: 1px solid rgba(124, 131, 253, 0.28);
}

.assistant-empty h4 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--text);
  font-weight: 650;
}

.assistant-empty p {
  margin: 0;
  max-width: 28rem;
}

.assistant-empty-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.assistant-empty-prompt {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.assistant-empty-prompt:hover {
  background: rgba(124, 131, 253, 0.12);
  border-color: rgba(124, 131, 253, 0.35);
}

.assistant-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(64rem, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 4px;
}

.assistant-row.is-user {
  /* Auto margins beat align-self — pin the You turn to the trailing edge. */
  margin-inline: auto 0;
  align-self: flex-end;
  align-items: flex-end;
  max-width: min(40rem, 100%);
}

.assistant-row.is-assistant {
  align-self: stretch;
  align-items: stretch;
}

.assistant-avatar {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.assistant-avatar .dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #818cf8;
}

.assistant-row.is-user .assistant-avatar .dot {
  background: rgba(93, 214, 197, 0.65);
}

.assistant-bubble {
  max-width: 100%;
  min-width: 0;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.assistant-row.is-user .assistant-bubble {
  max-width: 100%;
  background: rgba(93, 214, 197, 0.1);
  border: 1px solid rgba(93, 214, 197, 0.3);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.assistant-row.is-assistant .assistant-bubble {
  background: rgba(124, 131, 253, 0.08);
  border: 1px solid rgba(124, 131, 253, 0.22);
  border-radius: 14px;
  padding: 12px 16px;
}

.assistant-prose {
  font-size: 0.98rem;
  line-height: 1.75;
  color: #ececf1;
  overflow-x: auto;
}

.assistant-prose h1,
.assistant-prose h2,
.assistant-prose h3,
.assistant-prose h4 {
  color: #fff;
  margin: 1.15em 0 0.45em;
  line-height: 1.3;
  font-weight: 650;
}

.assistant-prose h1 { font-size: 1.28rem; }
.assistant-prose h2 { font-size: 1.12rem; }
.assistant-prose h3,
.assistant-prose h4 { font-size: 1.02rem; }

.assistant-prose p,
.assistant-prose ul,
.assistant-prose ol,
.assistant-prose pre,
.assistant-prose blockquote,
.assistant-prose table {
  margin: 0 0 0.85em;
}

.assistant-prose *:first-child {
  margin-top: 0;
}

.assistant-prose *:last-child {
  margin-bottom: 0;
}

.assistant-prose ul,
.assistant-prose ol {
  padding-left: 1.35em;
}

.assistant-prose li {
  margin: 0.25em 0;
}

.assistant-prose li + li {
  margin-top: 0.2em;
}

.assistant-prose a {
  color: #a5b4fc;
}

.assistant-prose code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  font-size: 0.88em;
}

.assistant-prose pre {
  background: #05060f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
}

.assistant-prose pre code {
  background: none;
  padding: 0;
}

.assistant-prose table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.assistant-prose th,
.assistant-prose td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  text-align: left;
}

.assistant-prose th {
  background: rgba(88, 80, 236, 0.14);
}

.assistant-prose blockquote {
  margin-left: 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid rgba(124, 131, 253, 0.5);
  color: #d4d4d8;
}

.assistant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-bottom: 4px;
}

.assistant-context-btn,
.assistant-tokens-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: #d4d4d8;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.assistant-context-btn:hover:not(:disabled),
.assistant-tokens-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
}

.assistant-context-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.assistant-context-btn .count {
  background: rgba(124, 131, 253, 0.28);
  color: #fff;
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}

.assistant-tokens-btn .assistant-tokens-icon {
  font-size: 0.78rem;
  line-height: 1;
}

.assistant-tokens-btn .assistant-tokens-label {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.assistant-row.is-streaming .assistant-bubble {
  background: rgba(124, 131, 253, 0.05);
  border: 1px dashed rgba(124, 131, 253, 0.28);
  border-radius: 14px;
  padding: 12px 16px;
}

.assistant-stream-text {
  margin: 0;
}

.assistant-stream-text:empty {
  display: none;
}

.assistant-stream-placeholder {
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.assistant-step-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.assistant-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.68rem;
  line-height: 1;
}

.assistant-step.is-done {
  color: rgba(214, 219, 255, 0.76);
  border-color: rgba(93, 214, 197, 0.20);
}

.assistant-step.is-done.is-tool {
  /* Tool-call chips read as a distinct event ("function-calling") and
     deserve their own visual tag so users can tell at a glance which
     steps were graph nodes vs which were the answer node firing a
     tool. */
  color: rgba(245, 158, 11, 0.92);
  border-color: rgba(245, 158, 11, 0.34);
  background: rgba(245, 158, 11, 0.06);
}

.assistant-step.is-done.is-tool .assistant-step-dot {
  background: rgba(245, 158, 11, 0.85);
}

.assistant-step.is-done.is-error {
  color: rgba(251, 113, 133, 0.95);
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.06);
}

.assistant-step.is-done.is-error .assistant-step-dot {
  background: rgba(251, 113, 133, 0.85);
}

.assistant-step.is-active {
  color: var(--text);
  border-color: rgba(124, 131, 253, 0.34);
  background: rgba(124, 131, 253, 0.10);
}

.assistant-step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(93, 214, 197, 0.72);
}

/* Morph chip: the one chip whose label rotates as each graph node
   completes. Replaces the old growing-list-of-chips design so the chat
   bubble stays the same height during a turn. */
.assistant-step-morph {
  cursor: help;
  transition: border-color 160ms ease, background 160ms ease;
}

.assistant-step-morph .assistant-step-label {
  font-weight: 500;
  letter-spacing: 0.01em;
}

.assistant-step-morph .assistant-step-elapsed {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.assistant-step-morph.is-error {
  /* Error border + tint applied to the morph chip itself when the last
     trace event reported a non-ok status. Tooltip still carries the
     full history with a ⚠ marker on the offending row. */
  color: rgba(251, 113, 133, 0.95);
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.08);
}

.assistant-step-tool-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(245, 158, 11, 0.95);
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.30);
  margin-left: 2px;
}

.assistant-thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.assistant-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(124, 131, 253, 0.55);
  animation: assistant-bounce 1.2s infinite ease-in-out both;
}

.assistant-thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.assistant-thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes assistant-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.45; }
  40% { transform: scale(1); opacity: 1; }
}

.assistant-composer {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  border-top: 0;
  border-radius: 0;
  padding: 8px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.assistant-composer-box {
  position: relative;
  width: min(64rem, 100%);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: #1a1c2e;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.assistant-mention-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 16px;
  right: 16px;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: #1a1c2e;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  z-index: 20;
}

.assistant-mention-menu.hidden {
  display: none;
}

.assistant-mention-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-mention-item:hover,
.assistant-mention-item.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.assistant-mention-empty {
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.assistant-attachment-chips {
  width: min(64rem, 100%);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.assistant-attachment-chips.hidden {
  display: none;
}

.assistant-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
  max-width: 220px;
}

.assistant-attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-attachment-chip-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

.assistant-attachment-chip-remove:hover {
  background: rgba(255, 255, 255, 0.22);
}

.assistant-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 6px 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  min-height: 28px;
  max-height: 180px;
  font-family: inherit;
}

.assistant-input:focus {
  outline: none;
}

.assistant-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.assistant-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.assistant-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.assistant-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.assistant-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin: 0;
}

.assistant-error {
  color: #f87171;
  font-size: 0.78rem;
  margin-top: 4px;
}

.modal-assistant-context,
.modal-assistant-usage {
  max-width: 760px;
  width: 92vw;
}

.assistant-context-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
}

.assistant-context-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 20px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
}

.assistant-context-card {
  background: rgba(124, 131, 253, 0.06);
  border: 1px solid rgba(124, 131, 253, 0.18);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-context-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 0.78rem;
}

.assistant-context-label {
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.assistant-context-file {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.assistant-context-heading {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.assistant-context-chip {
  background: rgba(124, 131, 253, 0.22);
  color: #fff;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
}

.assistant-context-source {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.assistant-context-snippet {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* RAG-aware assistant UI: routing badge, source chips, context modal
   sections, and session-memory summary cards. */
.assistant-rag-badge {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 0;
  display: inline-block;
  vertical-align: middle;
}

.assistant-rag-badge.is-rag {
  background: rgba(116, 247, 173, 0.18);
  color: #74f7ad;
  border: 1px solid rgba(116, 247, 173, 0.35);
}

.assistant-rag-badge.is-rule {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.34);
}

/* Model id when the turn ran an LLM without RAG grounding. */
.assistant-model-label {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  max-width: min(28rem, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* GENERAL badge: shown when retrieval was required but returned 0 chunks
   and the assistant answered from general knowledge instead of refusing. */
.assistant-rag-badge.is-general {
  background: rgba(124, 131, 253, 0.18);
  color: #b6bdff;
  border: 1px solid rgba(124, 131, 253, 0.4);
}

.assistant-source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.assistant-source-chip {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(124, 131, 253, 0.16);
  color: #b6bdff;
  border: 1px solid rgba(124, 131, 253, 0.28);
  padding: 2px 8px;
  border-radius: 999px;
}

.assistant-source-chip.is-more {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.assistant-context-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-subtle);
}

.assistant-context-section:last-child {
  border-bottom: none;
}

.assistant-context-section h5 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.assistant-context-subhead {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.assistant-context-stats,
.assistant-context-bullets {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
}

.assistant-context-stats {
  list-style: none;
  padding-left: 0;
}

.assistant-usage-kpis {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.assistant-usage-kpis li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.assistant-usage-kpis span {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.assistant-usage-kpis strong {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-usage-total-time {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.assistant-context-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.assistant-context-table th,
.assistant-context-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.assistant-context-table th {
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.66rem;
}

/* Token usage breakdown: right-align numeric columns so cost/token sums
   are scannable, and keep the model-id column readable. */
.assistant-usage-table th.assistant-usage-num,
.assistant-usage-table td.assistant-usage-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.assistant-usage-table td.assistant-usage-model {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.72rem;
  color: var(--text);
}

.assistant-usage-table tr.is-muted td {
  color: var(--text-muted);
}

.assistant-context-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 14px;
  font-size: 0.82rem;
}

.assistant-context-dl dt {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
}

/* Callout block at the top of the context modal that explains the
   "answered from general knowledge" fallback. Same accent as the
   GENERAL chat-row badge for visual consistency. */
.assistant-context-callout {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 14px;
  border: 1px solid rgba(124, 131, 253, 0.34);
  background: rgba(124, 131, 253, 0.12);
  color: var(--text);
}

.assistant-context-callout.is-warn {
  border-color: rgba(255, 184, 108, 0.4);
  background: rgba(255, 184, 108, 0.1);
}

.assistant-context-callout strong {
  color: var(--text);
}

.assistant-context-callout small {
  color: var(--text-muted);
}


/* Coming-soon stubs (Analytics + AI Assistant) */
.coming-soon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 48px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.coming-soon h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.coming-soon p {
  margin: 0;
  max-width: 460px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.coming-soon-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(124, 131, 253, 0.18);
  color: var(--tab-active-text);
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  padding: 16px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    position: static;
    height: auto;
    overflow: visible;
  }

  body.is-sidebar-collapsed .sidebar {
    width: 100% !important;
    min-height: 0;
    height: 0;
    padding: 0;
    border-bottom-color: transparent;
    opacity: 0;
    overflow: hidden;
  }

  .sidebar-brand {
    width: 100%;
  }

  .nav-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .nav-label {
    display: none;
  }

  .nav-list {
    flex-direction: row;
  }

  .main {
    padding: 24px 18px 40px;
  }

  body.is-sidebar-collapsed .main {
    padding-left: calc(18px + 34px + 12px);
  }

  .sidebar-expand-btn {
    top: 24px;
    left: 18px;
  }
}

/* ============================================================
   Toast notifications
   ------------------------------------------------------------
   Replaces native browser ``alert()`` dialogs with a consistent,
   non-blocking in-app surface. The stack lives bottom-right; each
   toast slides in, auto-dismisses, and supports info/success/error
   variants. Use ``SdlcApp._toast(message, { variant, title })``.
   ============================================================ */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left-width: 3px;
  border-radius: 10px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.3);
  color: var(--text);
  animation: toast-slide-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.toast.is-leaving {
  animation: toast-slide-out 200ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.toast-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  margin-top: 1px;
}

.toast-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.toast-message {
  font-size: 0.81rem;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.toast-close {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.toast-close:hover,
.toast-close:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

/* Variant: error */
.toast.toast-error {
  border-left-color: #f87171;
}
.toast.toast-error .toast-icon {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}

/* Variant: success */
.toast.toast-success {
  border-left-color: #4ade80;
}
.toast.toast-success .toast-icon {
  background: rgba(74, 222, 128, 0.14);
  color: #86efac;
}

/* Variant: info (default) */
.toast.toast-info {
  border-left-color: #818cf8;
}
.toast.toast-info .toast-icon {
  background: rgba(129, 140, 248, 0.16);
  color: #c7d2fe;
}

/* Variant: warning */
.toast.toast-warning {
  border-left-color: #fbbf24;
}
.toast.toast-warning .toast-icon {
  background: rgba(251, 191, 36, 0.14);
  color: #fcd34d;
}

@keyframes toast-slide-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 720px) {
  .toast-stack {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }
}

#btn-kb-move-to-review.is-busy {
  opacity: 0.7;
  cursor: progress;
}

/* Approve-time supersede suggestion modal */
.modal-supersedes {
  border-color: rgba(99, 102, 241, 0.28);
  box-shadow: var(--shadow-modal), 0 0 0 1px rgba(99, 102, 241, 0.12) inset;
}

.supersedes-candidate-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.supersedes-candidate {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.supersedes-candidate.is-selected {
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.12);
}

.supersedes-candidate input {
  margin-top: 3px;
}

.supersedes-candidate-body {
  flex: 1;
  min-width: 0;
}

.supersedes-candidate-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.supersedes-candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.supersedes-method-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  font-size: 0.75rem;
  font-weight: 600;
}

.supersedes-skip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 2px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.supersedes-skip input {
  margin-top: 3px;
}

/* ----- Organization panel ----- */
.view-organization {
  padding: 0 4px 32px;
}

.org-space-field {
  max-width: 420px;
  margin-bottom: 12px;
}

.org-active-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.org-active-card.muted {
  color: var(--text-muted);
}

.org-active-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.org-active-card-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.org-active-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.org-active-card-title #org-rename-input {
  min-width: 160px;
}

.org-active-card-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.btn-danger-text {
  color: #fca5a5 !important;
}

.btn-danger-text:hover {
  color: #fecaca !important;
  background: rgba(185, 28, 28, 0.15) !important;
}

.org-members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.org-member-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.org-space-picker {
  max-width: 420px;
}

.org-space-field .ux-select,
.modal-body .field .ux-select {
  width: 100%;
}

.org-space-field .ux-select-trigger,
.modal-body .field .ux-select-trigger {
  min-height: 42px;
  font-size: 0.9rem;
}

.org-space-field {
  position: relative;
  z-index: 1;
}

.org-space-field:has(.ux-select.is-open) {
  z-index: 40;
}

.org-invites-banner {
  background: rgba(124, 92, 255, 0.06);
  border: 1px solid rgba(124, 92, 255, 0.22);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.org-section-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.org-section-sub {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.approval-requests-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.request-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.request-tab {
  border: 1px solid var(--border-subtle);
  background: rgba(10, 11, 30, 0.45);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.request-tab:hover {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.35);
}

.request-tab.is-active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.14);
}

.approval-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(5, 6, 20, 0.35);
}

.approval-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.approval-group-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.approval-group-count {
  min-width: 1.5rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(124, 92, 255, 0.18);
  text-align: center;
}

.org-invite-list,
.approval-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(10, 11, 30, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid rgba(124, 92, 255, 0.35);
}

.approval-card.is-pending {
  border-left-color: #f59e0b;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.08), rgba(10, 11, 30, 0.35));
}

.approval-card.is-approved {
  border-left-color: #34d399;
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.07), rgba(10, 11, 30, 0.35));
}

.approval-card.is-rejected {
  border-left-color: #f97316;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.07), rgba(10, 11, 30, 0.35));
}

.approval-card-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.approval-card-kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.approval-card-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.approval-card-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.approval-card-sep {
  margin: 0 0.35em;
  opacity: 0.7;
}

.approval-card-aside,
.approval-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Legacy alias used by older invite markup */
.org-invite-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.org-invite-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.badge-role {
  background: rgba(124, 92, 255, 0.12);
  color: var(--accent);
  text-transform: capitalize;
}

.badge-pending {
  background: var(--badge-warn-bg);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

@media (max-width: 720px) {
  .approval-card {
    flex-direction: column;
    align-items: stretch;
  }

  .approval-card-aside,
  .approval-card-actions {
    justify-content: flex-start;
  }
}

/* ----- Platform admin console ----- */

.platform-admin-banner {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1a1528;
  background: linear-gradient(90deg, #e8dffc, #d4ecff);
  border-bottom: 1px solid rgba(124, 92, 255, 0.25);
  text-align: center;
}

.platform-admin-banner.is-readonly {
  color: #3a2a14;
  background: linear-gradient(90deg, #ffe8c2, #fff3d6);
  border-bottom-color: rgba(180, 120, 40, 0.35);
}

.admin-overview-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-actions {
  text-align: right;
  white-space: nowrap;
}

.view-admin {
  padding: 28px 32px 48px;
  max-width: 1100px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 20px;
}

.admin-tab {
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.875rem;
  cursor: pointer;
}

.admin-tab.is-active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.12);
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.admin-kpi {
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-kpi-btn {
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  width: 100%;
}

.admin-kpi-btn:hover {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.08);
}

.admin-kpi-action {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--accent);
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.admin-overview-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 14px 16px 10px;
}

.admin-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-overview-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.admin-overview-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-overview-list li {
  border-top: 1px solid var(--border-subtle);
}

.admin-overview-link,
.admin-overview-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 2px;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.admin-overview-link:hover {
  color: var(--accent);
}

.admin-overview-item {
  cursor: default;
}

.admin-kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-kpi-value {
  font-size: 1.5rem;
  font-weight: 600;
}

.admin-lead {
  color: var(--text-muted);
  max-width: 52rem;
  line-height: 1.5;
}

.admin-table {
  width: 100%;
}

.admin-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  max-width: 560px;
}

.admin-filter-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 10px 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-filter-field:focus-within {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.admin-filter-icon {
  display: inline-flex;
  color: var(--text-muted);
  margin-right: 8px;
  flex-shrink: 0;
}

.admin-filter-field input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 0;
  font-size: 0.9rem;
  outline: none;
  box-shadow: none;
}

.admin-filter-field input[type="search"]::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

.admin-filter-field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.admin-filter-clear {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.admin-filter-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.admin-filter-submit {
  flex-shrink: 0;
}

.admin-filter-hint {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-section-title {
  margin: 22px 0 10px;
  font-size: 0.95rem;
}

.admin-detail-header {
  margin-bottom: 8px;
}

.admin-detail-header h3 {
  margin: 10px 0 4px;
}

.admin-chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.admin-chat-row {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.admin-chat-row-user {
  background: rgba(124, 131, 253, 0.1);
}

.admin-chat-row strong {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.admin-chat-row p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.875rem;
}
