@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f2f6ff;
  --bg-alt: #e5efff;
  --text: #10223d;
  --muted: #4f5f7a;
  --panel: rgba(255, 255, 255, 0.86);
  --line: #c7d6f2;
  --primary: #0f62d6;
  --good: #1a7f37;
  --warn: #ad6a08;
  --bad: #b52b2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, #d6e7ff 0, transparent 40%),
    radial-gradient(circle at 95% 10%, #ffe7c8 0, transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg-alt));
  min-height: 100vh;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

.hero {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(240, 248, 255, 0.9));
}

.kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(1.8rem, 2.6vw, 2.4rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 14px;
}

.panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(6px);
}

.panel-form {
  margin-top: 14px;
}

.project-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 8px;
}

input,
select,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
  min-width: 0;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.project-form input,
.project-form button {
  width: 100%;
}

.form-helper {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dim {
  color: var(--muted);
}

.project-list,
.step-list,
.question-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.project-item {
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  color: inherit;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.project-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 98, 214, 0.15);
}

.project-item small {
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.meta small {
  color: var(--muted);
}

.step-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pill {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: #dfe6f5;
  color: #3d4b66;
}

.pill.ok {
  background: #def6e3;
  color: var(--good);
}

.pill.warn {
  background: #fff2dd;
  color: var(--warn);
}

.pill.bad {
  background: #ffe2e2;
  color: var(--bad);
}

.bar {
  height: 8px;
  background: #e8edf9;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0f62d6, #37a0ff);
}

.step-edit {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(70px, 90px) minmax(140px, 1fr) auto;
  gap: 8px;
}

.stats {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.stat h3 {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.stat p {
  margin: 8px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
  gap: 5px;
}

.row small {
  color: var(--muted);
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--primary);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

.toast.error {
  background: var(--bad);
}

.toast.ok {
  background: var(--good);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

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

.row-main {
  flex: 1;
  min-width: 0;
}

.row-main div,
.row-main small {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 61, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.modal-content h3 {
  margin: 0 0 14px;
}

.modal-content label {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.modal-content textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.modal-actions button[type="button"] {
  background: #e8edf9;
  color: var(--text);
}

/* Warn button (finalize) */
.btn-warn {
  background: var(--warn);
  color: #fff;
}

/* Finalized project indicator */
.project-item.finalized {
  opacity: 0.7;
  border-left: 3px solid var(--good);
}

.pill.finalized {
  background: #def6e3;
  color: var(--good);
  font-weight: 600;
}

/* Coverage Report */
.coverage-summary {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
}

.coverage-big {
  text-align: center;
}

.coverage-percent {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.coverage-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.coverage-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.coverage-tiers {
  display: grid;
  gap: 6px;
  flex: 1;
}

.tier-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.tier-row .tier-label {
  width: 80px;
  font-weight: 600;
}

.tier-row .tier-bar {
  flex: 1;
  height: 8px;
  background: #e8edf9;
  border-radius: 999px;
  overflow: hidden;
}

.tier-row .tier-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.tier-row.exact .tier-bar span { background: var(--good); }
.tier-row.similar .tier-bar span { background: var(--primary); }
.tier-row.partial .tier-bar span { background: var(--warn); }
.tier-row.none .tier-bar span { background: var(--bad); }

.tier-row .tier-count {
  width: 36px;
  text-align: right;
  font-weight: 600;
}

.coverage-sources {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.coverage-sources .source-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.coverage-sources .source-chip strong {
  display: block;
  font-size: 1.1rem;
}

/* Coverage tables */
.coverage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 12px;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.coverage-table th,
.coverage-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}

.coverage-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.coverage-table tr:last-child td {
  border-bottom: none;
}

/* Inline progress bar (used in coverage table) */
.bar.inline {
  display: inline-block;
  width: 80px;
  height: 6px;
  vertical-align: middle;
  margin-left: 6px;
}

/* Match tier badges on question rows */
.match-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.match-badge.exact { background: #def6e3; color: var(--good); }
.match-badge.similar { background: #dfe6f5; color: var(--primary); }
.match-badge.partial { background: #fff2dd; color: var(--warn); }
.match-badge.none { background: #ffe2e2; color: var(--bad); }

/* Question number badge */
.q-number {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary);
  margin-right: 4px;
}

/* Correct option badge */
.correct-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: #def6e3;
  color: var(--good);
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 4px;
}

@media (max-width: 1080px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .project-form {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
  .step-edit {
    grid-template-columns: 1fr;
  }
  .row {
    flex-direction: column;
  }
  .row-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
