* { box-sizing: border-box; }

.page {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e8eaed;
  color: #1a1d21;
  min-height: 100vh;
}

.header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-counter { font-size: 13px; color: #10b981; }

.tab-header {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-header:hover { background: #f3f4f6; color: #111827; }

/* Search hero - centered like reference */
.search-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 65vh;
  padding: 40px 24px;
  text-align: center;
  transition: all 0.4s ease;
}

.search-hero-compact {
  min-height: 0;
  padding: 16px 0;
  align-items: stretch;
  text-align: left;
}

.service-name {
  font-family: "Montserrat", sans-serif;
  margin: 0 0 6px;
  font-size: 42px;
  letter-spacing: -0.02em;
}

.service-name-bold { font-weight: 700; color: #111827; }
.service-name-light { font-weight: 400; color: #6b7280; }

.service-subtitle {
  font-family: "Montserrat", sans-serif;
  margin: 0 0 28px;
  font-size: 14px;
  font-weight: 400;
  color: #6b7280;
}

.search-hero-compact .service-name,
.search-hero-compact .service-subtitle { display: none; }

.search-hero .search-box {
  width: 100%;
  max-width: 560px;
}

.search-hero-compact .search-box { max-width: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding: 24px 40px 40px;
  transition: grid-template-columns 0.25s ease;
}

.layout.with-sidebar {
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  align-self: start;
}

.sidebar-title { margin-top: 0; margin-bottom: 12px; font-size: 16px; }
.filter-group { margin-bottom: 12px; }
.filter-label { display: block; font-size: 13px; margin-bottom: 4px; color: #4b5563; }

select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #e8eaed;
}


.search-box { display: flex; gap: 8px; }
.search-box input {
  flex: 1;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid #c4c8cc;
  background: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.search-box input::placeholder { color: #9ca3af; }
.search-box input:focus { border-color: #10b981; }
.search-box button {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  background: #10b981;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-box button:hover { background: #059669; }

.search-hint { font-size: 12px; color: #6b7280; }
.hint-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  margin-right: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.hint-pill:hover { background: #e0e7ff; }

.empty-state { margin-top: 40px; text-align: center; color: #6b7280; }
.empty-title { font-size: 16px; margin-bottom: 4px; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: #6b7280;
  font-size: 14px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  color: #991b1b;
  font-size: 13px;
}

/* Case tag (shared) */
.case-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
}
.rel-high { background: #dcfce7; color: #166534; }
.rel-mid { background: #fef9c3; color: #854d0e; }
.rel-low { background: #fee2e2; color: #991b1b; }

.case-card-link {
  font-size: 13px;
  color: #10b981;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.case-card-link:hover { color: #059669; }

/* Case badge (inside risk card & recommendations) */
.case-badge {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 6px;
}

.case-badge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.case-badge-title { font-size: 14px; color: #111827; }
.case-badge-taxpayer { font-size: 13px; color: #374151; margin-bottom: 2px; }
.case-badge-court { font-size: 12px; color: #6b7280; margin-bottom: 2px; }
.case-badge-meta { font-size: 12px; color: #9ca3af; margin-bottom: 4px; }
.case-badge-amount { font-size: 12px; color: #374151; font-weight: 500; margin-bottom: 2px; }
.case-badge-outcome-details { font-size: 12px; color: #6b7280; font-style: italic; margin-bottom: 4px; }
.case-badge-link { font-size: 12px; }

/* Outcome badges */
.outcome-win { background: #dcfce7; color: #166534; }
.outcome-partial { background: #fef9c3; color: #854d0e; }
.outcome-loss { background: #fee2e2; color: #991b1b; }
.outcome-overturned { background: #dbeafe; color: #1d4ed8; }
.outcome-unknown { background: #f3f4f6; color: #6b7280; }

/* Related cases inside risk card */
.risk-related-cases {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Recommendations section */
.recommendations-title {
  margin: 20px 0 8px;
  font-size: 15px;
  color: #6b7280;
  font-weight: 600;
}

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

.answer-title { margin: 0 0 8px; font-size: 18px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: #111827;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: background 0.15s;
}
.modal-close:hover { background: #e5e7eb; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* RAG Answer */
.answer { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.answer h2 { margin: 0; font-size: 18px; }

.risk-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  border-left: 4px solid #10b981;
}
.risk-title { margin: 0 0 6px; font-size: 15px; }
.risk-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.risk-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}
.risk-section { font-size: 13px; margin-bottom: 6px; line-height: 1.5; }
.risk-section-label { font-weight: 600; color: #374151; }

.risk-citations { margin-top: 8px; }
.risk-citations-title { font-size: 12px; font-weight: 600; color: #6b7280; margin-bottom: 4px; }
.citation-quote {
  margin: 4px 0;
  padding: 8px 12px;
  border-left: 3px solid #d1d5db;
  background: #f9fafb;
  font-style: italic;
  font-size: 12px;
  line-height: 1.5;
  color: #374151;
}
.citation-quote cite {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #6b7280;
  font-style: normal;
}

.disclaimer { font-size: 11px; color: #9ca3af; margin-top: 4px; }

/* Admin */
.admin-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.admin-toolbar select { width: auto; }

.btn-secondary {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}
.btn-secondary:hover { background: #f3f4f6; }

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}

.admin-cases {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  max-height: 70vh;
  overflow: auto;
}
.admin-cases h3 { margin: 0 0 6px; font-size: 14px; }

.case-list-item:hover { background: #f3f4f6; }
.case-list-item.active { background: #ecfdf3; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-approved { background: #10b981; }
.status-annotated { background: #f59e0b; }
.status-empty { background: #d1d5db; }

.case-year { margin-left: auto; font-size: 11px; color: #9ca3af; }
.case-risk-badge {
  font-size: 10px;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 1px 5px;
  border-radius: 999px;
}

.admin-detail {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  max-height: 70vh;
  overflow: auto;
}
.admin-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.btn-annotate {
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: #6366f1;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.btn-annotate:hover { background: #4f46e5; }
.btn-annotate:disabled { opacity: 0.6; cursor: not-allowed; }

.case-meta { margin-bottom: 6px; }
.meta-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}

.admin-text {
  font-size: 12px;
  line-height: 1.5;
  color: #4b5563;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
  background: #f9fafb;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.admin-risks { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.no-risks { font-size: 13px; color: #9ca3af; text-align: center; padding: 16px 0; }

.admin-risk-card {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
}
.admin-risk-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.risk-title-admin { font-size: 13px; font-weight: 600; }
.risk-status { font-size: 11px; }
.risk-status-approved { color: #10b981; }
.risk-status-pending { color: #f59e0b; }

.field-label { font-size: 11px; color: #6b7280; margin-top: 4px; }

.admin-risk-card textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  margin-top: 2px;
}

.admin-risk-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
}

.btn-save {
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: #10b981;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.btn-save:hover { background: #059669; }

.admin-risk-actions input[type="checkbox"] { margin-right: 4px; }

.admin-citations { margin-top: 8px; }
.admin-citations h4 { margin: 0 0 4px; font-size: 13px; }

/* Pipeline Stepper */
.pipeline-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px 0 20px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 0 12px;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.step-item.active .step-circle {
  background: #10b981;
  color: #fff;
}

.step-item.completed .step-circle {
  background: #6ee7b7;
  color: #065f46;
}

.step-label {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.step-item.active .step-label { color: #111827; font-weight: 600; }

.step-connector {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  min-width: 40px;
  max-width: 80px;
  margin-bottom: 20px;
}

.step-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.step-card h3 { margin: 0 0 16px; font-size: 16px; }

.step-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #111827;
}

.stat-label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.btn-primary {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: #10b981;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #059669; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.annotate-options { margin-bottom: 10px; }
.annotate-force-label { font-size: 13px; color: #6b7280; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.annotate-force-label input { cursor: pointer; }

.progress-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
  color: #166534;
}

/* Case list - enriched with metadata */
.case-list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  position: relative;
  padding-left: 22px;
}
.case-list-item .status-dot {
  position: absolute;
  left: 8px;
  top: 12px;
}
.case-main-info { font-size: 13px; }
.case-meta-line { font-size: 11px; color: #6b7280; }
.case-meta-line.tax-auth { color: #9ca3af; }

/* Meta rows in detail view */
.meta-row { font-size: 12px; margin-bottom: 4px; }
.meta-label { font-weight: 600; color: #374151; }
.meta-value { color: #4b5563; }

.hidden { display: none !important; }
