:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Outfit", "Segoe UI", system-ui, sans-serif;
}

button {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s ease;
}

button:hover {
  background: #2b354a;
  border-color: var(--muted);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

button.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button.success:hover {
  background: #059669;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

button.subtle {
  border: none;
  background: transparent;
  color: var(--muted);
}

button.subtle:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none !important;
}

input, select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: #0f172a;
  color: var(--text);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

h1 { font-size: 22px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.project-card {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.project-card .meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
}

.new-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border-style: dashed;
  border-width: 2px;
  color: var(--muted);
  cursor: pointer;
}

.new-card:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

/* Redesigned Workflow Cards */
.workflow-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 768px) {
  .workflow-selector {
    grid-template-columns: 1fr;
  }
}

.workflow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.workflow-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.15);
  background: linear-gradient(180deg, var(--surface) 0%, rgba(99, 102, 241, 0.03) 100%);
}

.workflow-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.workflow-card.vv .workflow-icon {
  background: var(--green-soft);
  color: var(--green);
}

.workflow-card:hover.vv {
  border-color: var(--green);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.15);
  background: linear-gradient(180deg, var(--surface) 0%, rgba(16, 185, 129, 0.03) 100%);
}

.workflow-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.workflow-desc {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0;
  line-height: 1.5;
}

/* Wizard step layout */
.wizard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .wizard-layout {
    grid-template-columns: 1fr;
  }
}

.wizard-steps {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  transition: all 0.2s ease;
}

.wizard-step:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.wizard-step.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.wizard-step.success.active {
  background: var(--green-soft);
  color: var(--green);
}

.wizard-step .circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

.wizard-step.done .circle {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* File Upload drag and drop zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.3);
  transition: all 0.2s ease;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone svg {
  margin-bottom: 12px;
  color: var(--muted);
}

/* Document Table and Badges */
.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}
.chip.purple { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.gray { background: #334155; color: var(--muted); }

/* Grounded-section sentence chips: shows exactly what's verified vs needs review */
.sentence { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 14px; line-height: 1.5; }
.sentence.verified { background: var(--green-soft); }
.sentence.cited { background: rgba(16, 185, 129, 0.08); }
.sentence.flagged { background: var(--amber-soft); }
.sentence.gap { background: rgba(255,255,255,0.04); color: var(--muted); }
.sentence .tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; margin-right: 8px; letter-spacing: .03em; }
.sentence.verified .tag { color: var(--green); }
.sentence.flagged .tag, .sentence.gap .tag { color: var(--amber); }
.sentence.cited .tag { color: var(--green); }
.sentence .refs { font-size: 11.5px; color: var(--muted); margin-left: 6px; }

/* Markdown Preview Box */
.md-preview {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: #e2e8f0;
  font-size: 14.5px;
  line-height: 1.7;
  max-height: 600px;
  overflow-y: auto;
}

.md-preview h1, .md-preview h2, .md-preview h3 {
  color: #fff;
  margin-top: 24px;
  margin-bottom: 12px;
}

.md-preview h1 { border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.md-preview p { margin: 0 0 16px; }

.md-preview ul, .md-preview ol { margin: 0 0 16px; padding-left: 20px; }

.md-preview code {
  background: #1e293b;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* V&V Traceability and test case blocks */
.req-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.req-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.req-body {
  font-size: 14.5px;
  background: #0f172a;
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

.req-body.dfmea {
  border-left-color: var(--amber);
}

.tc-card {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}

.tc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 13.5px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b4b;
  color: #e0e7ff;
  border: 1px solid var(--accent);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Modals */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 500px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  max-height: 88vh;
  overflow: auto;
}

/* Layout & text utilities used across the app */
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.mb { margin-bottom: 16px; }
.mt { margin-top: 16px; }
.small { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.banner.err { background: var(--red-soft); color: #fca5a5; border: 1px solid var(--red); }
.banner.ok { background: var(--green-soft); color: #6ee7b7; border: 1px solid var(--green); }
.banner.info { background: var(--accent-soft); color: #a5b4fc; border: 1px solid var(--accent); }

table.plain { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.plain th, table.plain td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.plain th { color: var(--muted); font-weight: 600; }

/* Settings: model provider choice cards */
.provider-card {
  border: 2px solid var(--border); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; flex: 1; transition: all 0.2s ease;
}
.provider-card:hover { border-color: var(--muted); }
.provider-card.selected { border-color: var(--accent); background: var(--accent-soft); }
