@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Source+Serif+4:wght@400;600&display=swap');

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

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  color: #2d2d2d;
  display: flex;
  min-height: 100vh;
  background: #f7f5f2;
}

/* Sidebar */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: #ebe8e4;
  padding: 20px 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
}

.sidebar-logo {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0 20px;
  margin-bottom: 28px;
  color: #2d2d2d;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8b8680;
  padding: 0 20px;
  margin-bottom: 6px;
  font-weight: 500;
}

.sidebar-link {
  display: block;
  padding: 7px 20px;
  font-size: 0.85rem;
  color: #5a554f;
  text-decoration: none;
  border-radius: 0;
  transition: all 0.1s;
  font-weight: 400;
}

.sidebar-link:hover {
  color: #2d2d2d;
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-link.active {
  color: #2d2d2d;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.06);
}

/* Content */
.content {
  flex: 1;
  margin-left: 240px;
  padding: 36px 48px;
  max-width: 820px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: #2d2d2d;
}

/* Forms */
form {
  margin-bottom: 32px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.form-row .form-field {
  flex: 1;
  margin-bottom: 0;
}

label {
  font-size: 0.78rem;
  font-weight: 500;
  color: #8b8680;
}

input {
  padding: 9px 12px;
  border: 1px solid #d4d0cc;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  background: #fff;
  color: #2d2d2d;
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: #b3714f;
  box-shadow: 0 0 0 3px rgba(179, 113, 79, 0.1);
}

input::placeholder {
  color: #b5b0aa;
}

/* Buttons */
.btn-primary, button[type="submit"] {
  padding: 9px 22px;
  background: #b3714f;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary:hover, button[type="submit"]:hover {
  background: #9c6345;
}

button:disabled {
  background: #c9b9ae;
  cursor: wait;
}

.btn-secondary {
  padding: 9px 22px;
  background: transparent;
  color: #5a554f;
  border: 1px solid #d4d0cc;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: #b5b0aa;
}

/* Status / Loading */
#status {
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: #8b8680;
}

.loading-sources {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loading-source {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 10px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

.loading-badge {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.loading-text {
  flex: 1;
}

.loading-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #2d2d2d;
}

.loading-desc {
  font-size: 0.7rem;
  color: #8b8680;
  margin-top: 1px;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e5e1dd;
  border-top-color: #b3714f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Wizard */
#wizard {
  display: none;
  margin-bottom: 28px;
  padding: 24px;
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
}

.wizard-step {
  font-size: 0.65rem;
  color: #8b8680;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  font-weight: 500;
}

.wizard-question {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #2d2d2d;
}

.wizard-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.pill {
  padding: 6px 16px;
  border: 1px solid #d4d0cc;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  background: #fff;
  color: #5a554f;
  font-family: 'Inter', sans-serif;
}

.pill:hover {
  border-color: #b3714f;
  color: #b3714f;
}

.pill.selected {
  background: #b3714f;
  color: #fff;
  border-color: #b3714f;
}

.pill-label {
  display: block;
  font-weight: 500;
}

.pill-detail {
  display: block;
  font-size: 0.65rem;
  opacity: 0.65;
  margin-top: 1px;
  line-height: 1.3;
}

.pill.selected .pill-detail {
  opacity: 0.8;
}

.pill:has(.pill-detail) {
  padding: 6px 16px 8px;
  text-align: left;
}

.wizard-actions {
  display: flex;
  gap: 10px;
}

/* Results */
#results {
  display: none;
}

.result-card {
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}

.result-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.source-tag {
  font-size: 0.6rem;
  color: #8b8680;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px;
  font-weight: 500;
}

.match-name {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: #2d2d2d;
}

.match-type {
  color: #8b8680;
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
}

.match-summary {
  color: #5a554f;
  font-size: 0.82rem;
  margin-top: 4px;
  line-height: 1.5;
}

.match-link {
  font-size: 0.75rem;
  margin-top: 6px;
}

.match-link a {
  color: #b3714f;
  text-decoration: none;
}

.match-link a:hover {
  text-decoration: underline;
}

.meta {
  color: #8b8680;
  font-size: 0.7rem;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #e5e1dd;
}

.no-results {
  color: #8b8680;
  font-size: 0.9rem;
  padding: 28px 0;
}

.error-source {
  color: #c4553d;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

/* Sources page */
.source {
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}

.source:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.source-name {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
  color: #2d2d2d;
}

.source-url {
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.source-url a {
  color: #b3714f;
  text-decoration: none;
}

.source-url a:hover {
  text-decoration: underline;
}

.source-desc {
  font-size: 0.82rem;
  color: #5a554f;
  line-height: 1.55;
}

.source-auth {
  font-size: 0.7rem;
  color: #8b8680;
  margin-top: 8px;
}

/* Mobile: sidebar becomes top bar */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    overflow-x: auto;
  }

  .sidebar-logo {
    margin-bottom: 0;
    padding: 0;
    white-space: nowrap;
  }

  .sidebar-section {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
  }

  .sidebar-label {
    display: none;
  }

  .sidebar-link {
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
  }

  .content {
    margin-left: 0;
    padding: 20px 16px;
    max-width: 100%;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-field {
    margin-bottom: 12px;
  }

  .wizard-actions {
    flex-direction: column;
  }

  .wizard-actions button {
    width: 100%;
  }
}

.steps-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 24px 0 8px;
  margin-bottom: 8px;
}

.step-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-dot::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d4d0cc;
  display: block;
}

.step-dot.step-active::before {
  background: #b3714f;
  box-shadow: 0 0 0 3px rgba(179, 113, 79, 0.2);
}

.step-dot.step-done::before {
  background: #b3714f;
}

.step-label {
  font-size: 0.7rem;
  color: #8b8680;
  margin-top: 6px;
  white-space: nowrap;
}

.step-dot.step-active .step-label {
  color: #b3714f;
  font-weight: 600;
}

.step-dot.step-done .step-label {
  color: #5a554f;
}

.step-line {
  width: 48px;
  height: 2px;
  background: #d4d0cc;
  margin: 0 8px;
  margin-bottom: 20px;
}

.step-line.step-done {
  background: #b3714f;
}

.wizard-card {
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
  padding: 24px;
}

.report-progress-card {
  background: #faf8f6;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
}

.report-timer {
  font-size: 2.5rem;
  font-weight: 300;
  color: #b3714f;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.report-progress-label {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: #3a3530;
  margin-bottom: 12px;
}

.report-ready-card {
  background: #fff;
  border: 1px solid #e5e1dd;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
}

.report-checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 28px;
  line-height: 56px;
  margin: 0 auto 16px;
  animation: checkPop 0.4s ease-out;
}

@keyframes checkPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.report-ready-subject {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: #3a3530;
  margin-bottom: 16px;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.risk-badge.risk-LOW { background: #e8f5e9; color: #2e7d32; }
.risk-badge.risk-MEDIUM { background: #fff3cd; color: #856404; }
.risk-badge.risk-HIGH { background: #f8d7da; color: #721c24; }
.risk-badge.risk-CRITICAL { background: #dc3545; color: #fff; }

.risk-badge-level {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.risk-badge-score {
  font-size: 0.8rem;
  opacity: 0.8;
}

.report-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.report-stat {
  text-align: center;
  min-width: 70px;
}

.report-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: #3a3530;
  line-height: 1;
}

.report-stat-label {
  font-size: 0.7rem;
  color: #8b8680;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-download-large {
  display: inline-block;
  padding: 14px 36px;
  font-size: 1rem;
}

.report-ready-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.files-details {
  margin-top: 16px;
}

.files-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #8b8680;
  padding: 8px 0;
  user-select: none;
}

.files-details summary:hover {
  color: #5a554f;
}

.files-list {
  margin-top: 8px;
}

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-bottom: 1px solid #f0eeeb;
}

.file-row:last-child {
  border-bottom: none;
}

.file-name {
  color: #3a3530;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.file-status {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.file-status-found {
  background: #e8f5e9;
  color: #2e7d32;
}

.file-status-empty {
  color: #8b8680;
}

.file-status-error {
  color: #c62828;
}

.error-message {
  background: #ffebee;
  color: #c62828;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.btn-report {
  display: inline-block;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.btn-brief {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  background: #fff;
  color: #5a554f;
  border: 1px solid #d4d0cc;
  margin-left: 8px;
}

.btn-brief:hover {
  background: #f5f5f5;
}

.report-progress {
  font-size: 0.85rem;
  color: #5a554f;
  padding: 12px 0;
}
