:root {
  --bg: #0a0a0f;
  --card-bg: #16141f;
  --border: #2a2438;
  --purple: #a855f7;
  --purple-dark: #7c3aed;
  --text: #f3f0fa;
  --text-muted: #a89fc2;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --gray: #9ca3af;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  background: linear-gradient(90deg, #1a1626, #100c1a);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.brand {
  color: var(--purple);
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 {
  color: var(--text);
  border-left: 4px solid var(--purple);
  padding-left: 0.75rem;
  margin-bottom: 1.5rem;
}

h2 {
  color: var(--purple);
  font-size: 1.1rem;
  margin: 0;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { color: var(--purple); }

.upload-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="file"], input[type="number"] {
  background: #0d0b14;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--purple);
  color: #0a0a0f;
}
.btn-primary:hover { background: var(--purple-dark); color: #fff; }
.btn-primary:disabled {
  background: #332b47;
  color: #6b6280;
  cursor: not-allowed;
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.4);
}
.btn-danger:hover { background: rgba(239,68,68,0.15); }

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.dashboard-header h1 { margin-bottom: 0; }

.dashboard-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pdf-list {
  display: grid;
  gap: 0.75rem;
}

.pdf-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  transition: border-color 0.15s ease;
}
.pdf-card:hover { border-color: var(--purple); }

.pdf-card-link {
  display: flex;
  flex: 1;
  min-width: 0;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.pdf-name { font-weight: 600; }

.stage-dots { display: flex; gap: 0.4rem; }
.pill {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #241f30;
  color: #6b6280;
  border: 1px solid var(--border);
}
.pill-on {
  background: var(--purple);
  color: #0a0a0f;
  border-color: var(--purple);
}

.tab-nav {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn-active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

.tab-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #241f30;
  border: 1px solid var(--border);
}
.tab-dot-on { background: var(--purple); border-color: var(--purple); }

h3 {
  color: var(--text);
  font-size: 0.95rem;
  margin: 1.5rem 0 0.75rem;
}

.stage-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.run-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-ghost {
  background: transparent;
  color: var(--purple);
  border: 1px solid rgba(168,85,247,0.5);
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { background: rgba(168,85,247,0.12); }

.stage-summary { color: var(--text-muted); font-size: 0.9rem; margin: 0.35rem 0 0; }

.next-step { margin-top: 1rem; }
.next-step a, .empty a { color: var(--purple); }

.report-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* The report reads as a document: a light "paper" sheet on the dark app. */
.doc {
  background: #fbfaf7;
  color: #1f1b2b;
  border-radius: 6px;
  padding: 2.5rem 3rem;
  max-width: 820px;
  margin: 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.6;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
}
.doc-head { border-bottom: 2px solid #3c1e6e; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.doc-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: #6b5b8a;
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}
.doc-title { color: #1f1b2b; font-size: 1.5rem; margin: 0.3rem 0; word-break: break-word; }
.doc-meta { color: #6b6280; font-size: 0.85rem; margin: 0; }
.doc-disclaimer {
  background: #fdecec;
  border-left: 3px solid #c0392b;
  color: #7a1f1f;
  font-size: 0.8rem;
  padding: 0.6rem 0.8rem;
  margin: 1rem 0 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}
.doc-section { margin-bottom: 1.75rem; }
.doc h3 {
  color: #3c1e6e;
  font-size: 1.1rem;
  border-bottom: 1px solid #ddd5ea;
  padding-bottom: 0.3rem;
  margin: 0 0 0.75rem;
}
.doc-note { color: #5c5470; font-style: italic; }
.doc-list { padding-left: 1.3rem; margin: 0; }
.doc-list li { margin-bottom: 1.25rem; }
.doc-list h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.doc dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
.doc dt {
  font-weight: 700;
  font-size: 0.8rem;
  color: #5c5470;
  padding-top: 0.15rem;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}
.doc dd { margin: 0; }
.clause { margin-top: 0.5rem; font-size: 0.85rem; }
.clause summary { cursor: pointer; color: #6d3fc0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
.clause blockquote {
  white-space: pre-line;
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid #ddd5ea;
  background: #f3f0f8;
  color: #3d3550;
  max-height: 320px;
  overflow-y: auto;
}
.doc-source { font-size: 0.85rem; color: #5c5470; margin: 0.4rem 0 0; }
.doc-foot {
  border-top: 1px solid #ddd5ea;
  padding-top: 0.75rem;
  color: #5c5470;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .doc { padding: 1.5rem 1.25rem; }
  .doc dl { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .topbar, .back-link, .dashboard-header, .tab-nav, .report-toolbar { display: none; }
  .container { padding: 0; max-width: none; }
  .doc { box-shadow: none; padding: 0; max-width: none; }
  .clause blockquote { max-height: none; }
}

.empty { color: var(--text-muted); font-style: italic; }

.scroll-table {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.result-table th {
  position: sticky;
  top: 0;
  background: #1e1a2b;
  color: var(--purple);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.result-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.result-table tr:hover td { background: #1c1826; }

.quote-cell {
  color: var(--text-muted);
  max-width: 360px;
}

.verdict-summary {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-pass { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.4); }
.badge-fail { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.4); }
.badge-flag { background: rgba(245,158,11,0.15); color: var(--amber); border: 1px solid rgba(245,158,11,0.4); }
.badge-no-matching-clause { background: rgba(156,163,175,0.15); color: var(--gray); border: 1px solid rgba(156,163,175,0.4); }
.badge-all { background: rgba(168,85,247,0.15); color: var(--purple); border: 1px solid rgba(168,85,247,0.4); }

.badge-filter {
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.badge-filter:hover { opacity: 0.85; }
.badge-filter.badge-active {
  box-shadow: 0 0 0 2px var(--purple);
  transform: translateY(-1px);
}

/* "Watching" eyes shown while a stage runs: they close and open, and the
   pupils glance side to side like they're reading the drawing. */
.eyes {
  display: none;
  gap: 5px;
  align-items: center;
}
.eyes.blinking { display: inline-flex; }
.eye {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f3f0fa;
  border: 2px solid var(--purple);
  position: relative;
  overflow: hidden;
  animation: blink 1.6s ease-in-out infinite;
}
.pupil {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple-dark);
  top: 50%;
  left: 50%;
  margin: -3.5px 0 0 -3.5px;
  animation: glance 3.2s ease-in-out infinite;
}
@keyframes blink {
  0%, 40%, 60%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.08); }
}
@keyframes glance {
  0%, 100% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce) {
  .eye, .pupil { animation: none; }
}
