* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --success: #059669;
  --warning: #D97706;
  --danger: #B91C1C;
  --bg: #F8FAFC;
  --card: #ffffff;
  --text: #1C1917;
  --text-muted: #57534E;
  --border: #E7E5E4;
}

body {
  font-family: var(--font, 'Inter'), sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

header {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #0ea5e9 100%);
  color: white;
  padding: 48px 0 64px;
  text-align: center;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

header p {
  font-size: 1.1rem;
  opacity: 0.95;
  max-width: 600px;
  margin: 0 auto;
}

.search-section {
  margin-top: -32px;
  margin-bottom: 48px;
}

.search-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: 16px 32px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(20,99,86,0.25);
}

.quick-select {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-btn {
  padding: 8px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.loading {
  display: none;
  text-align: center;
  padding: 48px;
}

.loading.active {
  display: block;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.results {
  display: none;
  width: 100%;
}

.results.active {
  display: block;
  width: 100%;
}

.source-card {
  background: var(--primary-light, #E3F1EE);
  border: 1px solid #BFE0D8;
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.source-title h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  color: var(--primary);
}

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

.meta-badge {
  padding: 6px 12px;
  background: white;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 32px;
  background: var(--primary);
  border-radius: 4px;
}

.matches-grid {
  width: 100%;
  max-width: 100%;
}

.match-card {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.match-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.match-card.selected {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(20,99,86,0.15);
}

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

.similarity-score {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.match-badge {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.match-badge.high {
  background: transparent;
  color: var(--success);
  border: 1.5px solid var(--success);
}

.match-badge.medium {
  background: transparent;
  color: var(--warning);
  border: 1.5px solid var(--warning);
}

.match-badge.low {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.match-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.match-info {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.info-pill {
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.coverage-bar {
  margin-top: 16px;
}

.coverage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.analysis-section {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.comparison-column h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.9rem;
}

.icon.success {
  background: rgba(13,148,136,0.1);
  color: var(--success);
}

.icon.info {
  background: rgba(6,95,70,0.1);
  color: var(--primary);
}

.icon.warning {
  background: rgba(217,119,6,0.1);
  color: var(--warning);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.chip.common {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.chip.unique {
  background: transparent;
  border-color: var(--success);
  color: var(--success);
}

.chip.missing {
  background: transparent;
  border-color: var(--warning);
  color: var(--warning);
}

.insights-box {
  background: var(--primary-light, #E3F1EE);
  border-left: 4px solid var(--primary);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 32px;
}

.insights-box h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--primary);
}

.insights-list {
  list-style: none;
}

.insights-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: start;
  gap: 12px;
}

.insights-list li:last-child {
  border-bottom: none;
}

.insights-list li::before {
  content: '→';
  color: var(--primary);
  font-weight: 700;
  font-size: 1.2rem;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  opacity: 0.3;
}

@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }

  .search-box {
    flex-direction: column;
  }

  .matches-grid {
    grid-template-columns: 1fr;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }
}
