/* ─── Animatable custom properties (enables smooth dark-mode transition on gradient backgrounds) */
@property --bg {
  syntax: '<color>';
  inherits: true;
  initial-value: #f5f4f7;
}
@property --border {
  syntax: '<color>';
  inherits: true;
  initial-value: #e2dde8;
}

/* ─── CSS Variables ─────────────────────────────────────────────── */
:root {
  --primary:       #72246c;
  --primary-dark:  #5a1c55;
  --primary-light: #9b3594;
  --grad-purple:   linear-gradient(to top right, #672D89 20%, #72246c 70%, #c2188b 100%);
  --success:       #48a23f;
  --warning:       #f0b323;
  --danger:        #dc6b2f;
  --info:          #41b6e6;
  --teal:          #0D9488;
  --pink:          #c2188b;

  --bg:      #f5f4f7;
  --surface: #ffffff;
  --border:  #e2dde8;
  --text:    #1a1523;
  --muted:   #7a6e85;

  --radius:  8px;
  --shadow:  0 2px 8px rgba(114,36,108,0.08);
  --shadow-lg: 0 4px 24px rgba(114,36,108,0.14);
  --sidebar-width: 260px;
}

[data-theme="dark"] {
  --bg:      #12101a;
  --surface: #1e1a2a;
  --border:  #2e2840;
  --text:    #f0ecf8;
  --muted:   #9b90ae;
  --shadow:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);
}

/* ─── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { transition: background-color 0.2s, color 0.2s; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Split shorthand to prevent repaint quirks on CSS variable change */
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; }

/* ─── Navbar ────────────────────────────────────────────────────── */
.navbar {
  background-color: var(--surface);
  border-bottom: 2px solid transparent;
  border-image: var(--grad-purple) 1;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow);
  transition: background-color 0.2s;
}

.navbar-brand { display: flex; align-items: center; flex-shrink: 0; }
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
}
.brand-link:hover { text-decoration: none; opacity: 0.85; }
.brand-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  color: var(--primary);
}
.brand-icon svg { width: 100%; height: 100%; }
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--primary); }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.navbar-links a, .nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.15s;
  text-decoration: none;
}
.navbar-links a:hover, .nav-link:hover { background: var(--bg); text-decoration: none; }
.navbar-links a.active, .nav-link.active { background: var(--bg); font-weight: 600; color: var(--primary); }

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

.nav-user {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}

/* ─── Container & Layout ────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.page-body { min-height: calc(100vh - 60px); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(114,36,108,0.07) 0%, rgba(65,182,230,0.05) 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.page-header h1 { font-size: 1.6rem; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  transition: background-color 0.2s, border-color 0.2s;
}
.section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-header h3 { font-size: 1rem; font-weight: 600; }

.link-button {
  display: inline;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.link-button:hover { text-decoration: underline; }

.back-btn {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: background-color 0.2s, border-color 0.2s;
}

.chart-card h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.chart-canvas-wrap {
  height: 240px;
  min-height: 240px;
}

.source-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}

.extracted-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--muted);
  padding: 18px 20px;
  max-height: 520px;
  overflow-y: auto;
}

.source-meta-list {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 0.88rem;
}
.source-meta-list dt { color: var(--muted); }
.source-meta-list dd { min-width: 0; overflow-wrap: anywhere; }
.source-card-divider {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.source-original-link {
  width: 100%;
  justify-content: center;
}
.source-side-notice { margin-top: 16px; }

.invite-form-panel {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.invite-form-panel[hidden] { display: none; }
.invite-form-panel.is-visible { display: block; }

.bulk-toolbar {
  display: none;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bulk-toolbar.visible { display: flex; }
.bulk-count {
  color: var(--muted);
  font-size: 0.9rem;
  margin-right: auto;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.col-check { width: 44px; }
.entity-filter-bar {
  margin: 0;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
}
.requirement-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}
.entity-section-body {
  padding: 18px 20px;
}
.entity-edit-card {
  margin-top: 16px;
}
.entity-edit-card h2,
.requirement-detail-card h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}
.entity-detail-list {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 0.88rem;
}
.entity-detail-list dt,
.entity-detail-label {
  color: var(--muted);
  font-weight: 700;
}
.entity-source-quote strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  text-transform: uppercase;
}
.entity-table-quote {
  margin-top: 6px;
  font-size: 0.75rem;
  max-width: 420px;
}
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.export-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-card h3 {
  font-size: 1rem;
}
.export-card p {
  color: var(--muted);
  font-size: 0.86rem;
  flex: 1;
}
.export-card form,
.export-card button,
.export-card a {
  width: 100%;
  justify-content: center;
}
.export-icon {
  font-size: 2rem;
  line-height: 1;
}
.export-format-actions {
  display: grid;
  gap: 8px;
}
.export-card-disabled {
  opacity: 0.72;
}
.export-history-section .section-body {
  padding: 14px;
}
.export-history-icon {
  font-size: 1.1rem;
  margin-right: 6px;
}
.filter-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}
.filter-confidence-val {
  min-width: 28px;
  color: var(--muted);
  font-size: 0.86rem;
}

.ai-toast {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.ai-toast-visible { display: flex; }
.ai-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  background: var(--primary);
}
.ai-toast-success .ai-toast-icon { background: var(--success); }
.ai-toast-error .ai-toast-icon { background: var(--danger); }
.ai-toast-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ai-toast-body span {
  color: var(--muted);
  font-size: 0.86rem;
}
.ai-toast-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.ai-toast-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tiq-spin 0.8s linear infinite;
}
@keyframes tiq-spin { to { transform: rotate(360deg); } }

/* ─── Project Sidebar Layout ─────────────────────────────────────── */
.project-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 60px);
}

.project-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  transition: background-color 0.2s;
}

.project-sidebar-title {
  padding: 20px 16px 8px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.project-sidebar-meta {
  padding: 0 16px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.sidebar-section-label {
  padding: 10px 16px 2px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 0.88rem;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.sidebar-link:hover {
  background-color: var(--bg);
  text-decoration: none;
  color: var(--primary);
}
.sidebar-link.active {
  background-color: rgba(114,36,108,0.1);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.sidebar-link-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-badge {
  margin-left: auto;
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 0.73rem;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.project-main {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background-color 0.2s, border-color 0.2s;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* Project cards on dashboard */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.project-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s, background-color 0.2s, border-color 0.2s;
  color: var(--text);
}
.project-card:hover { box-shadow: var(--shadow-lg); }
.project-card-archived { opacity: 0.6; }
.project-card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.project-card-name,
.project-card-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.project-card-desc { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.project-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }

/* ─── Entity Grid (8 types) ─────────────────────────────────────── */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.entity-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.12s, background-color 0.2s, border-color 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.entity-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; color: var(--text); }
.entity-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin: 0 auto 10px;
  color: #fff;
}
.entity-card-count { font-size: 1.8rem; font-weight: 700; line-height: 1; margin-bottom: 4px; color: var(--text); }
.entity-card-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

/* Entity icon background colours */
.ec-requirements  { background: #72246c; }
.ec-stakeholders  { background: #c2188b; }
.ec-processes     { background: #41b6e6; }
.ec-decisions     { background: #0D9488; }
.ec-risks         { background: #dc6b2f; }
.ec-business-rules{ background: #f0b323; color: #1a1523 !important; }
.ec-systems       { background: #48a23f; }
.ec-kpis          { background: #672D89; }

/* ─── Entity List ───────────────────────────────────────────────── */
.entity-list { display: flex; flex-direction: column; gap: 10px; }
.entity-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.15s;
}
.entity-item:hover { border-color: var(--primary); }
.entity-item-main { flex: 1; min-width: 0; }
.entity-item-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.entity-item-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.entity-item-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.entity-item-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ─── Filter Bar ────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background-color 0.2s, border-color 0.2s;
}
.filter-bar select, .filter-bar input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.filter-bar label { font-size: 0.85rem; color: var(--muted); }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge-success  { background: #d1fae5; color: #065f46; padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-warning  { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-danger   { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-info     { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-muted    { background: var(--bg); color: var(--muted); padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 500; border: 1px solid var(--border); display: inline-block; }
.badge-primary  { background: rgba(114,36,108,0.12); color: var(--primary); padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-role     { background: rgba(114,36,108,0.1); color: var(--primary); padding: 2px 9px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: capitalize; display: inline-block; border: 1px solid rgba(114,36,108,0.2); }

.confidence-badge { padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.confidence-high   { background: #d1fae5; color: #065f46; }
.confidence-medium { background: #fef3c7; color: #92400e; }
.confidence-low    { background: #fee2e2; color: #991b1b; }
.confidence-badge-high { background: #d1fae5; color: #065f46; }
.confidence-badge-med  { background: #fef3c7; color: #92400e; }
.confidence-badge-low  { background: #fee2e2; color: #991b1b; }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-outline:hover { background: rgba(114,36,108,0.07); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-danger:hover { opacity: 0.85; text-decoration: none; color: #fff; }
.btn-warning {
  background: var(--warning);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sm { padding: 5px 12px !important; font-size: 0.82rem !important; }

/* ─── Forms ─────────────────────────────────────────────────────── */
.form-page { max-width: 680px; margin: 0 auto; padding: 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.form-label { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.form-hint { font-size: 0.8rem; color: var(--muted); }
.danger-zone {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: var(--radius);
  background: rgba(220, 38, 38, 0.06);
}
.danger-zone h3 { margin: 0 0 8px; color: var(--danger); font-size: 1rem; }
.danger-zone p { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ─── Upload drop-zone ───────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
  background-color: var(--bg);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background-color: rgba(114,36,108,0.04);
}
.drop-zone-icon { font-size: 2.2rem; margin-bottom: 10px; }
.drop-zone-text { color: var(--muted); font-size: 0.9rem; margin-bottom: 4px; }
.drop-zone-link { color: var(--primary); cursor: pointer; font-weight: 600; text-decoration: underline; }
.drop-zone-hint { color: var(--muted); font-size: 0.78rem; }
.drop-zone-selected { color: var(--text); font-size: 0.88rem; font-weight: 500; margin-top: 10px; }
.alt-link { display: inline-block; margin-top: 16px; color: var(--muted); font-size: 0.88rem; }
.alt-link:hover { color: var(--primary); }
.extraction-status { color: var(--muted); font-size: 0.88rem; }

.form-input, .form-textarea, .form-select {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, background-color 0.2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(114,36,108,0.12);
}
.form-textarea { resize: vertical; min-height: 100px; }

/* ─── Auth Pages ────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 28px; }
.auth-logo {
  width: 54px; height: 54px;
  background: var(--grad-purple);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #fff;
}
.alt-actions { margin-top: 20px; font-size: 0.88rem; color: var(--muted); text-align: center; }

/* ─── Pipeline Hero ─────────────────────────────────────────────── */
.pipeline-hero {
  background: var(--grad-purple);
  border-radius: 14px;
  padding: 32px;
  margin-bottom: 28px;
  color: #fff;
}
.pipeline-title, .pipeline-hero h1 { font-size: 1.4rem; margin-bottom: 6px; color: #fff; }
.pipeline-sub, .pipeline-hero p { opacity: 0.88; font-size: 0.95rem; color: #fff; }
.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  color: #fff;
}
.pipeline-arrow { color: rgba(255,255,255,0.5); font-size: 1rem; flex-shrink: 0; padding: 0 2px; }
/* Both class names supported */
.pipeline-step-num, .step-num {
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-label { font-size: 0.82rem; font-weight: 600; }

/* ─── Members section ───────────────────────────────────────────── */
.members-list { padding: 8px 0; }
.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.member-item:last-child { border-bottom: none; }
.member-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-purple);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 0.9rem; }
.member-email { color: var(--muted); font-size: 0.82rem; }

/* ─── Source Items ───────────────────────────────────────────────── */
.source-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  transition: border-color 0.15s;
}
.source-item:hover { border-color: var(--primary); }
.source-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: rgba(114,36,108,0.1);
}
.source-main { flex: 1; min-width: 0; }
.source-name { font-weight: 600; font-size: 0.95rem; }
.source-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.status-pending   { color: var(--muted); }
.status-done      { color: var(--success); }
.status-failed    { color: var(--danger); }
.status-processing{ color: var(--info); }

.upload-success-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 20px;
  border: 1px solid rgba(72,162,63,0.3);
  border-radius: var(--radius);
  background: rgba(72,162,63,0.08);
  color: var(--text);
}
.upload-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.upload-success-link {
  margin-left: auto;
  font-weight: 700;
  color: var(--primary);
}
.sources-table td,
.sources-table th {
  vertical-align: middle;
}
.table-method {
  max-width: 160px;
  overflow-wrap: anywhere;
}
.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.table-help {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 500;
}
.table-error { color: var(--danger); }

.duplicate-review-panel {
  margin-bottom: 18px;
  border: 1px solid rgba(240, 179, 35, 0.55);
  border-radius: var(--radius);
  background: rgba(240, 179, 35, 0.08);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.duplicate-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(240, 179, 35, 0.32);
}
.duplicate-review-header h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.duplicate-review-header p { margin: 0; color: var(--muted); }
.duplicate-review-list {
  display: grid;
  gap: 0;
}
.duplicate-review-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(240, 179, 35, 0.22);
}
.duplicate-review-row:last-child { border-bottom: 0; }
.duplicate-review-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.duplicate-review-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.duplicate-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
}

.stakeholder-filter-bar {
  padding: 14px 18px;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.stakeholders-table .row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stakeholder-edit-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(130px, 1fr) minmax(150px, 1fr) 90px 90px auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
}
.stakeholder-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.inline-actions { display: flex; gap: 6px; align-items: center; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.6);
}
.modal-backdrop[hidden] { display: none; }
.modal-panel {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

/* ─── Drag & Drop Upload ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.upload-zone.dragover,
.upload-zone:hover { border-color: var(--primary); background-color: rgba(114,36,108,0.04); }
.upload-zone-icon { font-size: 3rem; margin-bottom: 12px; }
.upload-zone h3 { margin-bottom: 6px; }
.upload-zone p { color: var(--muted); font-size: 0.88rem; }

/* ─── Knowledge Graph ────────────────────────────────────────────── */
.graph-canvas {
  width: 100%;
  height: 620px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--surface);
}
.graph-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* ─── Risk Heatmap ───────────────────────────────────────────────── */
.heatmap-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  cursor: default;
  transition: opacity 0.15s;
  border: 1px solid rgba(0,0,0,0.08);
}
.heatmap-cell:hover { opacity: 0.85; }
.heatmap-critical { background: #dc2626; color: #fff; }
.heatmap-high     { background: #ea580c; color: #fff; }
.heatmap-medium   { background: #f59e0b; color: #fff; }
.heatmap-low      { background: #84cc16; color: #fff; }
.heatmap-y-label  { font-size: 0.75rem; color: var(--muted); text-align: right; padding-right: 6px; display: flex; align-items: center; justify-content: flex-end; }
.heatmap-x-label  { font-size: 0.75rem; color: var(--muted); text-align: center; }
.risk-heatmap-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 20px;
}
.heatmap-matrix {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  overflow-x: auto;
  padding-top: 10px;
}
.heatmap-axis {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding-top: 46px;
}
.heatmap-header-row,
.heatmap-row {
  display: grid;
  grid-template-columns: 80px repeat(5, minmax(72px, 1fr));
  gap: 4px;
  margin-bottom: 4px;
  align-items: stretch;
}
.heatmap-header-row div,
.heatmap-row-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.heatmap-cell {
  min-width: 72px;
  min-height: 72px;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.heatmap-cell-empty {
  background: var(--bg);
  color: var(--muted);
}
.heatmap-cell-low { background: #d1fae5; color: #065f46; }
.heatmap-cell-med { background: #fef3c7; color: #92400e; }
.heatmap-cell-high { background: #fed7aa; color: #c2410c; }
.heatmap-cell-critical { background: #dc2626; color: #fff; }
.heatmap-cell-count { font-size: 1rem; font-weight: 800; }
.heatmap-cell-label { font-size: 0.75rem; opacity: 0.85; }
.heatmap-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}
.heatmap-detail ul { margin-top: 10px; padding-left: 20px; }
.heatmap-high-badge { background: #fed7aa; color: #c2410c; }

/* ─── RACI Table ─────────────────────────────────────────────────── */
.raci-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.raci-table th, .raci-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: center; }
.raci-table th { background-color: var(--bg); font-weight: 600; }
.raci-table td:first-child { text-align: left; font-weight: 500; }
.raci-table select { border: none; background: transparent; color: var(--text); font-size: 0.82rem; cursor: pointer; padding: 2px 4px; }
.raci-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 200px;
}
.raci-cell {
  min-width: 86px;
  height: 48px;
  cursor: pointer;
  font-weight: 800;
}
.raci-table.raci-readonly .raci-cell { cursor: default; }
.raci-R { background: rgba(72,162,63,0.18); color: #166534; }
.raci-A { background: rgba(114,36,108,0.18); color: var(--primary); }
.raci-C { background: rgba(65,182,230,0.18); color: #0369a1; }
.raci-I { background: rgba(240,179,35,0.22); color: #92400e; }
.raci-S { background: rgba(220,107,47,0.18); color: #9a3412; }
.save-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  background: var(--success);
  color: #fff;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
}

/* ─── Process Map ────────────────────────────────────────────────── */
.process-layout { display: flex; gap: 20px; }
.process-sidebar { width: 260px; flex-shrink: 0; }
.process-main { flex: 1; min-width: 0; }
.process-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 0.88rem;
}
.process-item:hover, .process-item.active { border-color: var(--primary); background: rgba(114,36,108,0.05); }
.mermaid-canvas {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 320px;
  overflow: auto;
}
.process-map-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.process-map-list {
  padding: 12px;
}
.process-map-list h3 {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.process-map-link {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.86rem;
}
.process-map-link:hover,
.process-map-link.active {
  background: rgba(114,36,108,0.1);
  color: var(--primary);
  font-weight: 700;
}
.mermaid-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 20px;
  overflow-x: auto;
}
.process-steps {
  margin-top: 20px;
}
.process-steps h3 {
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.process-steps ol {
  padding-left: 22px;
}
.process-steps li {
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.source-quote {
  margin-top: 16px;
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
  background: rgba(114,36,108,0.06);
  color: var(--muted);
  font-size: 0.86rem;
}

.stakeholder-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
.stakeholder-chart-container {
  height: 620px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}
.stakeholder-side-list h3 {
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.stakeholder-side-row {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}
.stakeholder-side-row:last-child { border-bottom: 0; }
.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.quadrant-grid div {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.quadrant-grid strong,
.quadrant-grid span {
  display: block;
  font-size: 0.8rem;
}
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }

.gap-list { display: grid; gap: 12px; padding: 14px; }
.gap-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}
.gap-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.gap-row { font-size: 0.88rem; margin-top: 5px; }
.gap-label { color: var(--muted); font-weight: 700; }
.gap-issue { color: var(--muted); margin-bottom: 8px; }
.gap-recommendation {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(72,162,63,0.08);
}
.reco-list { padding: 14px 24px; }
.reco-list li { margin-bottom: 8px; }

/* ─── Insights nav ───────────────────────────────────────────────── */
.insights-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 8px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.insights-nav a {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.insights-nav a:hover { background: var(--bg); color: var(--text); }
.insights-nav a.active { background: var(--primary); color: #fff; }

/* ─── Story cards ────────────────────────────────────────────────── */
.story-card { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.story-card .ac-list { margin-top: 8px; padding-left: 20px; font-size: 0.85rem; color: var(--muted); }
.ac-block { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.ac-block h4 { margin-bottom: 10px; font-size: 0.95rem; }
.ac-block p { margin-bottom: 4px; font-size: 0.88rem; }

/* ─── Impact matrix ──────────────────────────────────────────────── */
.impact-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.impact-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.82rem; margin-top: 8px; }

/* ─── Roadmap ────────────────────────────────────────────────────── */
.phase-block { margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background-color: var(--surface); }
.phase-header { padding: 12px 16px; background-color: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.phase-header h3 { font-size: 0.95rem; font-weight: 700; }
.task-list { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.task-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 7px; background-color: var(--bg); border-left: 3px solid var(--border); }
.task-item.task-status-done        { border-left-color: var(--success); }
.task-item.task-status-in_progress { border-left-color: var(--info); }
.task-item.task-status-blocker     { border-left-color: var(--danger); }
.task-item.task-status-cancelled   { opacity: 0.5; }
.task-title { flex: 1; font-size: 0.88rem; }
.task-meta  { display: flex; align-items: center; gap: 8px; }
.task-status-select {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.container-wide { max-width: 1440px; }
.insight-generated-at { color: var(--muted); font-size: 0.85rem; margin: 14px 0; }
.insight-empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.insight-empty h3 { color: var(--text); margin-bottom: 8px; }
.insight-empty-icon { font-size: 2rem; margin-bottom: 10px; color: var(--primary); }
.insight-section { margin: 18px 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.insight-section h2 { font-size: 1.05rem; margin-bottom: 12px; }
.insight-narrative { white-space: pre-line; color: var(--text); }
.insight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.insight-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--bg); }
.insight-card p { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.insight-value-tag { display: inline-flex; margin-top: 8px; padding: 4px 8px; border-radius: 999px; background: rgba(72,162,63,.14); color: var(--success); font-weight: 700; font-size: 0.78rem; }
.insight-change-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.insight-change-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; }
.insight-change-col { padding: 12px; border-radius: 8px; border: 1px solid var(--border); }
.insight-current { background: rgba(220,107,47,.08); }
.insight-future { background: rgba(72,162,63,.08); }
.insight-change-label, .section-kicker { display: block; text-transform: uppercase; font-size: 0.72rem; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.insight-change-arrow { align-self: center; color: var(--muted); font-weight: 800; }
.insight-change-list, .insight-list, .story-criteria { margin-left: 18px; margin-top: 10px; color: var(--text); }
.insight-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.process-map-wrap { margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.process-map-title { padding: 10px 14px; font-weight: 800; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.process-map-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.process-map-diagram { padding: 16px; overflow-x: auto; min-height: 90px; }
.process-map-diagram .mermaid svg { max-width: 100%; height: auto; }
.process-map-editor { padding: 12px 14px 16px; }
.mermaid-edit-area { font-family: "Courier New", monospace; font-size: 0.82rem; min-height: 90px; margin-bottom: 8px; }
#pmZoomOverlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 9998; align-items: center; justify-content: center; }
#pmZoomOverlay.open { display: flex; }
#pmZoomBox { background: var(--surface); border-radius: var(--radius); padding: 22px; width: 92vw; max-width: 92vw; max-height: 90vh; overflow: auto; position: relative; box-shadow: 0 8px 40px rgba(0,0,0,.35); }
#pmZoomClose { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 1.6rem; cursor: pointer; }
#pmZoomTitle { font-weight: 800; margin-bottom: 12px; padding-right: 30px; }
.pm-zoom-controls { display: flex; gap: 8px; margin-bottom: 12px; }
#pmZoomContent { overflow: auto; }
#pmZoomContent svg { max-width: none; display: block; }

.roadmap-summary-bar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 16px 0; flex-wrap: wrap; }
.roadmap-summary-label { font-weight: 800; }
.roadmap-overall-bar, .roadmap-phase-progress-bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.roadmap-overall-bar { flex: 1; min-width: 180px; }
.roadmap-overall-fill, .roadmap-phase-progress-fill { height: 100%; background: var(--success); transition: width .2s ease; }
.roadmap-overall-pct, .roadmap-total-estimate { color: var(--muted); font-size: 0.85rem; }
.roadmap-rationale p { color: var(--muted); margin: 0; }
.roadmap-phase { margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.roadmap-phase-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.roadmap-phase-num { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; }
.phase-color-1 { background: var(--success); }
.phase-color-2 { background: var(--warning); color: #1f1a05; }
.phase-color-3 { background: var(--info); color: #04151c; }
.roadmap-phase-name { font-weight: 800; flex: 1; }
.roadmap-phase-duration { color: var(--muted); font-size: 0.85rem; }
.roadmap-phase-body { padding: 16px; }
.roadmap-phase-progress-wrap { margin: 12px 0; }
.roadmap-phase-progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.roadmap-task-list { display: flex; flex-direction: column; gap: 10px; }
.roadmap-task-row { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg); }
.roadmap-task-row.status-done { border-left-color: var(--success); }
.roadmap-task-row.status-in_progress { border-left-color: var(--info); }
.roadmap-task-row.status-blocker { border-left-color: var(--danger); }
.roadmap-task-row.status-deferred { border-left-color: var(--warning); }
.roadmap-task-row.status-cancelled { opacity: .62; }
.task-row-top, .task-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-row-top { margin-bottom: 8px; }
.done-title { text-decoration: line-through; color: var(--muted); }
.task-save-indicator { opacity: 0; color: var(--success); font-size: 0.78rem; transition: opacity .2s ease; }
.task-save-indicator.visible { opacity: 1; }
.task-field-label { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.task-input { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 9px; }
.task-notes-toggle { border: 0; background: none; color: var(--primary); cursor: pointer; font-weight: 700; }
.task-notes-area { margin-top: 8px; }
.task-rationale { margin-top: 8px; font-size: 0.8rem; }
.roadmap-phase-extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 14px; }
.roadmap-phase-extra h4 { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }

.story-card-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.story-text { font-size: 0.96rem; color: var(--text); }
.story-points-badge { border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; color: var(--muted); font-size: 0.78rem; }
.story-criteria-wrap { margin-top: 10px; }
.story-criteria li { margin-bottom: 4px; }
.ac-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.ac-item-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ac-item-title { font-weight: 800; flex: 1; }
.ac-criterion { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.ac-gwt { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: start; }
.ac-gwt-label { padding: 2px 8px; border-radius: 999px; font-weight: 800; font-size: 0.72rem; }
.ac-given { background: rgba(65,182,230,.16); color: var(--info); }
.ac-when { background: rgba(240,179,35,.18); color: var(--warning); }
.ac-then { background: rgba(72,162,63,.16); color: var(--success); }
.impact-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.impact-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.impact-table th, .impact-table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.impact-table th { background: var(--bg); font-size: 0.78rem; text-transform: uppercase; color: var(--muted); }
.impact-tag { display: inline-flex; margin: 2px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.78rem; }
.effort-high { color: var(--danger); font-weight: 800; }
.effort-medium { color: var(--warning); font-weight: 800; }
.effort-low { color: var(--success); font-weight: 800; }

/* ─── Voice controls ─────────────────────────────────────────────── */
.voice-controls { display: flex; gap: 10px; }

/* ─── Stakeholder map ────────────────────────────────────────────── */
.stakeholder-chart-wrap { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: 640px; }

/* ─── Gap analysis ───────────────────────────────────────────────── */
.gap-state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.gap-state-card { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.gap-state-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; }
.gap-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.gap-item:last-child { border-bottom: none; }
.rec-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.rec-item:last-child { border-bottom: none; }
.rec-num { background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; margin-top: 1px; }

/* ─── Detail / entity pages ─────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.detail-meta { display: flex; flex-direction: column; gap: 12px; }
.detail-meta-item { font-size: 0.88rem; }
.detail-meta-item label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 4px; }
.source-quote {
  background-color: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 8px;
}
.extracted-text-block {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.7;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

/* ─── Traceability matrix ────────────────────────────────────────── */
.trace-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.trace-table th, .trace-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.trace-table th { background-color: var(--bg); }
.trace-table td:first-child { text-align: left; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-link { background: var(--primary); color: #fff !important; border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; }

/* ─── Future state layers ────────────────────────────────────────── */
.layer-card { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border-left: 4px solid var(--primary); }
.layer-card h4 { margin-bottom: 6px; font-size: 0.95rem; }
.layer-card ul { padding-left: 20px; font-size: 0.88rem; color: var(--muted); }
.sso-flow { background-color: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; font-size: 0.82rem; color: var(--muted); }

/* ─── Admin usage table ──────────────────────────────────────────── */
.students-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.students-table th, .students-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.students-table th { background-color: var(--bg); font-weight: 600; }
.students-table tr:last-child td { border-bottom: none; }
.students-table tr:hover td { background-color: var(--bg); }

/* ─── Flash messages ─────────────────────────────────────────────── */
.flash-wrap { padding: 8px 24px 0; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ─── Empty state ────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state p { font-size: 0.95rem; }

/* ─── Notice / callout blocks ────────────────────────────────────── */
.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.6;
  border: 1px solid transparent;
}
.notice-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.notice-info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.notice-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.notice-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
[data-theme="dark"] .notice-warning { background: #78350f; color: #fef3c7; border-color: #92400e; }
[data-theme="dark"] .notice-info    { background: #1e3a5f; color: #bfdbfe; border-color: #2563eb; }
[data-theme="dark"] .notice-success { background: #065f46; color: #d1fae5; border-color: #047857; }
[data-theme="dark"] .notice-danger  { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }

/* ─── Voice Capture ─────────────────────────────────────────────── */
.voice-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.rec-btn:hover:not(:disabled) { transform: scale(1.07); }
.rec-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.rec-btn-start { background: #22c55e; color: #fff; }
.rec-btn-pause { background: #f59e0b; color: #fff; }
.rec-btn-stop  { background: #ef4444; color: #fff; }
.rec-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.speaker-label { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.speaker-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.speaker-chip {
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  border: 2px solid transparent;
  font-weight: 500;
  transition: border-color 0.1s;
}
.speaker-chip.active { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); }
.voice-new-turn { margin-left: auto; }
.voice-page { display: flex; flex-direction: column; gap: 16px; }
.voice-speaker-panel, .voice-controls-card, .voice-review-panel, .voice-save-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.voice-speaker-header, .voice-review-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.voice-speaker-form, .voice-copy-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.voice-speaker-form .form-input { flex: 1; min-width: 160px; }
.speaker-chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.speaker-chip-row .speaker-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; }
.speaker-chip-row .speaker-chip-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(114,36,108,.18); }
.speaker-chip-num { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 0.75rem; font-weight: 800; }
.speaker-chip-remove { margin-left: 4px; color: var(--danger); font-weight: 900; }
.mic-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mic-btn:disabled { opacity: .35; cursor: not-allowed; }
.mic-btn-start { background: var(--success); }
.mic-btn-pause { background: var(--warning); color: #1f1a05; }
.mic-btn-stop { background: var(--danger); }
.mic-status { min-width: 190px; }
.mic-status-text { font-weight: 800; }
.mic-status-sub { color: var(--muted); font-size: 0.85rem; }
.mic-pulse { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); margin-right: 6px; box-shadow: 0 0 0 rgba(239,68,68,.6); animation: micPulse 1.4s infinite; }
@keyframes micPulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 70% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.voice-filter-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; }
.voice-current-speaker { color: var(--text); font-weight: 700; }
.transcript-box { min-height: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.transcript-placeholder { color: var(--muted); }
.speaker-turn { border-left: 3px solid var(--primary); padding: 8px 12px; margin-bottom: 10px; background: var(--bg); border-radius: 0 8px 8px 0; }
.speaker-turn-label { font-size: 0.78rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.speaker-turn-text { white-space: pre-wrap; }
.speaker-turn-interim { opacity: .72; border-left-color: var(--info); }
.transcript-interim { color: var(--muted); font-style: italic; }
.transcript-word-count { color: var(--muted); font-size: 0.85rem; text-align: right; }
.voice-review-list { display: flex; flex-direction: column; gap: 10px; }
.voice-review-empty { color: var(--muted); text-align: center; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); }
.voice-review-turn { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg); }
.voice-review-turn-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.voice-review-speaker { max-width: 260px; }
.voice-review-text { width: 100%; }
.voice-copy-status { color: var(--success); font-size: 0.85rem; margin-top: 8px; }
.voice-copy-status-error { color: var(--danger); }

/* ─── Misc helpers ───────────────────────────────────────────────── */
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border); background-color: var(--bg); color: var(--text); }

/* ─── Footer ─────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 20px 24px; color: var(--muted); font-size: 0.82rem; margin-top: 48px; border-top: 1px solid var(--border); }

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .project-layout { flex-direction: column; }
  .project-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 8px 0;
  }
  .project-sidebar-title { padding: 8px 16px; font-size: 0.8rem; }
  .project-sidebar-meta  { padding: 4px 16px 8px; }
  .sidebar-section-label { display: none; }
  .sidebar-link { padding: 6px 12px; font-size: 0.82rem; }
  .project-main { padding: 16px; }
}

@media (max-width: 768px) {
  .nav-toggle { display: block; margin-left: auto; }
  .navbar-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    z-index: 199;
    box-shadow: var(--shadow-lg);
  }
  /* BUG FIX: was .navbar-links.open — toggle adds 'open' to .navbar, not .navbar-links */
  .navbar.open .navbar-links { display: flex; }
  .navbar-links a { padding: 10px 14px; }
  .navbar { position: relative; }
  .navbar-right { gap: 6px; }
  .nav-user { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .source-detail-grid { grid-template-columns: 1fr; }
  .requirement-detail-grid { grid-template-columns: 1fr; }
  .gap-state-grid { grid-template-columns: 1fr; }
  .process-layout { flex-direction: column; }
  .process-sidebar { width: 100%; }
  .stakeholder-edit-form,
  .duplicate-review-row,
  .process-map-layout,
  .stakeholder-map-layout,
  .quadrant-grid {
    grid-template-columns: 1fr;
  }
  .stakeholder-chart-container { height: 520px; }
  .pipeline-steps { gap: 4px; }
  .pipeline-step { padding: 7px 10px; font-size: 0.78rem; }
}

@media (max-width: 640px) {
  .container { padding: 16px; }
  .project-main { padding: 12px; }
  .entity-grid { grid-template-columns: repeat(2, 1fr); }
  .projects-grid { grid-template-columns: 1fr; }
  .page-body { padding-bottom: 16px; }
  .auth-card { padding: 28px 20px; }
  .pipeline-hero { padding: 20px; }
  .btn-primary, .btn-outline, .btn-danger, .btn-warning { width: 100%; justify-content: center; }
  .form-actions { flex-direction: column; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; }
  .row-actions { width: 100%; }
  .filter-bar { align-items: stretch; }
  .filter-sep { display: none; }
  .heatmap-matrix { gap: 10px; }
  .heatmap-header-row,
  .heatmap-row {
    grid-template-columns: 56px repeat(5, minmax(60px, 1fr));
  }
  .heatmap-cell {
    min-width: 60px;
    min-height: 60px;
  }
  input, select, textarea { font-size: 1rem; }
}

/* ─── Dark mode overrides for hardcoded colours ─────────────────── */
[data-theme="dark"] .badge-success  { background: #065f46; color: #d1fae5; }
[data-theme="dark"] .badge-warning  { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .badge-danger   { background: #7f1d1d; color: #fee2e2; }
[data-theme="dark"] .badge-info     { background: #1e3a5f; color: #bfdbfe; }
[data-theme="dark"] .confidence-high   { background: #065f46; color: #d1fae5; }
[data-theme="dark"] .confidence-medium { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .confidence-low    { background: #7f1d1d; color: #fee2e2; }
[data-theme="dark"] .flash-success { background: #065f46; color: #d1fae5; border-color: #047857; }
[data-theme="dark"] .flash-error   { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }
[data-theme="dark"] .flash-warning { background: #78350f; color: #fef3c7; border-color: #92400e; }
[data-theme="dark"] .flash-info    { background: #1e3a5f; color: #bfdbfe; border-color: #2563eb; }
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select,
[data-theme="dark"] .task-status-select,
[data-theme="dark"] .filter-bar select,
[data-theme="dark"] .filter-bar input { background-color: var(--bg); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .ec-business-rules { color: #fff !important; }
