/* Base and layout */
* { box-sizing: border-box; }
:root {
  --bg: #0a0f1e;
  --surface: #111827;
  --surface-2: #182035;
  --surface-3: #1e293b;
  --border: #27334c;
  --text: #e5e8ef;
  --muted: #8a95aa;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #15203a 0%, var(--bg) 55%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 1.75rem; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  margin-bottom: 0.75rem;
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-subtitle { color: var(--muted); margin: 0; font-size: 0.9rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--accent); }

.login-hint { margin-top: 1rem; font-size: 0.8rem; color: var(--muted); text-align: center; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
}

.sidebar-brand {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-name { font-weight: 600; font-size: 1.1rem; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--accent); }
.nav-icon { width: 18px; text-align: center; }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }

.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 1.75rem;
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 1.25rem; }
.page-header h2 { margin: 0 0 0.35rem; font-size: 1.6rem; }
.page-subtitle { color: var(--muted); margin: 0; font-size: 0.9rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.metric-card { text-align: center; }
.metric-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.metric-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.placeholder-card { color: var(--muted); text-align: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-secondary { background: var(--surface-3); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.35); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-loader {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.idea-input,
.search-input {
  width: 100%;
  padding: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 1rem;
}

.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Filter bar & pagination */
.card.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.card.search-bar .search-input {
  flex: 1;
  min-width: 220px;
  margin-bottom: 0;
}

.filter-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.filter-group input,
.filter-group select {
  min-width: 130px;
}

.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pagination-bar button {
  min-width: 2rem;
}

.pagination-bar .page-info {
  font-size: 0.85rem;
  color: var(--muted);
}

.action-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: rgba(248, 113, 113, 0.12); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.25); }
.alert-success { background: rgba(52, 211, 153, 0.12); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.25); }
.alert-info { background: rgba(56, 189, 248, 0.12); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.25); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-idea { background: rgba(56, 189, 248, 0.15); color: var(--accent); }
.badge-discovery { background: rgba(129, 140, 248, 0.15); color: var(--accent-2); }
.badge-prototype { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.badge-pilot { background: rgba(251, 191, 36, 0.25); color: #f59e0b; }
.badge-production { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-maintained { background: rgba(52, 211, 153, 0.25); color: #10b981; }
.badge-paused { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge-retired { background: rgba(139, 147, 162, 0.2); color: var(--muted); }
.badge-stale { background: rgba(248, 113, 113, 0.25); color: var(--danger); }

/* Idea results */
.similarity-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}
.similarity-score {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.score-high { background: rgba(248, 113, 113, 0.2); color: var(--danger); }
.score-medium { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.score-low { background: rgba(56, 189, 248, 0.2); color: var(--accent); }
.score-unique { background: rgba(52, 211, 153, 0.2); color: var(--success); }

/* Maturity dashboard */
.maturity-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stage-distribution {
  display: grid;
  gap: 0.6rem;
}
.stage-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stage-label { width: 90px; font-size: 0.85rem; color: var(--muted); }
.stage-bar-bg {
  flex: 1;
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.stage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 5px;
  transition: width 0.5s ease;
}
.stage-count { width: 30px; text-align: right; font-size: 0.85rem; }

/* Maturity dimension bars */
.dimension-row {
  display: grid;
  grid-template-columns: 180px 1fr 50px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.dimension-label { font-size: 0.85rem; color: var(--muted); }
.dimension-bar-bg {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.dimension-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 5px;
  transition: width 0.5s ease;
}
.dimension-score { font-weight: 600; font-size: 0.85rem; text-align: right; }

/* Project list cards */
.project-card {
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.project-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.project-card p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.85rem; }
.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-score {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

/* Loading */
.dashboard-horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-horizontal .similarity-card,
.dashboard-horizontal .project-card {
  flex: 1 1 260px;
  max-width: 320px;
  margin-bottom: 0;
}

.dashboard-horizontal .empty-state,
.dashboard-horizontal .loading {
  flex: 1 1 100%;
}

.dashboard-section {
  margin-top: 1rem;
}

.dashboard-section .card {
  overflow-x: auto;
}

.dashboard-section .card > h3 {
  position: sticky;
  left: 0;
}

.dashboard-section .project-list {
  min-width: 720px;
}

.stage-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.stage-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.stage-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.list-header,
.list-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) minmax(300px, 3fr) 120px 100px;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 0.4rem;
}

.list-header {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.list-row {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.list-row:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--border);
}

.list-col-name {
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.list-col-idea {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
}

.list-col-stage {
  text-align: right;
}

.list-col-actions {
  text-align: right;
}

.list-col-actions .btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.pie-chart {
  width: 160px;
  height: 160px;
  border-radius: 50%;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.pie-legend-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pie-legend-row strong {
  margin-left: auto;
}

.pie-legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.similarity-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.similarity-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.similarity-row:hover {
  background: rgba(56, 189, 248, 0.08);
}

.similarity-info {
  flex: 0 0 40%;
  min-width: 180px;
}

.similarity-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.similarity-team {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.similarity-bar-wrap {
  flex: 1;
  height: 10px;
  background: var(--card-bg);
  border-radius: 999px;
  overflow: hidden;
}

.similarity-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  border-radius: 999px;
}

.similarity-score {
  flex: 0 0 80px;
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.member-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.member-row:last-child {
  border-bottom: none;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 0.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* Maturity score ring */
.score-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.score-ring svg { position: absolute; transform: rotate(-90deg); }
.score-ring-value { font-weight: 700; font-size: 1.1rem; }

/* Modal / overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Comments */
.comment-form { background: var(--surface-2); }
.comment-thread { transition: margin-left 0.2s; }
.comment-card { background: var(--surface-2); padding: 0.85rem 1rem; }
.badge-collaboration-note {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

/* Activity timeline */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.activity-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
}
/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  min-width: 240px;
  max-width: 360px;
  font-size: 0.9rem;
  animation: slideIn 0.2s ease;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Focus outlines */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
  }
  .sidebar-brand { border-bottom: none; padding: 0.5rem; }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
    flex: 1;
  }
  .nav-item { padding: 0.4rem 0.6rem; }
  .sidebar-footer { border-top: none; padding: 0.5rem; }
  .main-content { margin-left: 0; padding: 1rem; }
  .card-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .modal { max-width: 100%; }
  .dimension-row { grid-template-columns: 1fr 60px; }
  .dimension-bar-bg { order: 3; grid-column: 1 / -1; }
}

/* Print */
@media print {
  .sidebar, .sidebar-footer, .action-bar, .pagination-bar { display: none; }
  .main-content { margin-left: 0; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; color: #000; }
}
