/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #1a1a2e;
  --navy-light: #222240;
  --navy-lighter: #2a2a4a;
  --white: #ffffff;
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f5;
  --gray-200: #e2e5e9;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-800: #1f2937;

  --highlight: #d4a017;
  --highlight-bg: #fdf8e8;
  --highlight-border: #e8c84a;

  --critical: #dc2626;
  --critical-bg: #fef2f2;
  --critical-border: #fca5a5;

  --high: #ea580c;
  --high-bg: #fff7ed;
  --high-border: #fdba74;

  --medium: #ca8a04;
  --medium-bg: #fefce8;
  --medium-border: #fde047;

  --low: #2563eb;
  --low-bg: #eff6ff;
  --low-border: #93c5fd;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header --- */
.header {
  background: var(--navy);
  padding: 20px 0;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--gray-400);
  font-size: 0.875rem;
  font-weight: 400;
}

/* --- Hero --- */
.hero {
  padding: 60px 0 40px;
  text-align: center;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.hero-sub {
  color: var(--gray-500);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 560px;
  margin: 0 auto 36px;
}

/* --- Search Form --- */
.search-form {
  max-width: 600px;
  margin: 0 auto;
}

.input-group {
  display: flex;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
  box-shadow: var(--shadow-md);
}

.input-group:focus-within {
  border-color: var(--navy);
}

.input-group input {
  flex: 1;
  padding: 16px 20px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--gray-800);
  background: transparent;
}

.input-group input::placeholder {
  color: var(--gray-400);
}

.input-group button {
  padding: 16px 28px;
  background: var(--navy);
  color: var(--white);
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.input-group button:hover {
  background: var(--navy-light);
}

.input-group button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Spinner */
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading .btn-text { display: none; }
.loading .btn-spinner { display: block; }

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

/* --- Results --- */
.results {
  padding: 0 0 60px;
  animation: fadeIn 0.4s ease;
}

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

.results-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
}

.results-url {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 4px;
  word-break: break-all;
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}

.btn-disabled:hover {
  background: var(--white);
  border-color: var(--gray-200);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--navy-light);
}

/* --- Score Display --- */
.score-container {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.score-card-display {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 28px 40px;
  text-align: center;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
}

.score-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
}

.score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.score-number {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--white);
  transition: color 0.3s;
}

.score-number.score-critical { color: var(--critical); }
.score-number.score-high { color: var(--high); }
.score-number.score-medium { color: #eab308; }
.score-number.score-ok { color: #16a34a; }

.score-max {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--gray-400);
}

.score-bar-track {
  margin-top: 14px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #dc2626 0%, #f59e0b 50%, #16a34a 100%);
  transition: width 0.8s ease;
}

.score-verdict {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--gray-400);
  line-height: 1.5;
}

/* --- Findings --- */
.findings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finding-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  border-left: 4px solid;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.finding-card:hover {
  box-shadow: var(--shadow-md);
}

.finding-card.severity-highlight {
  border-left-color: var(--highlight);
  background: var(--highlight-bg);
}

.finding-card.severity-critical {
  border-left-color: var(--critical);
  background: var(--critical-bg);
}

.finding-card.severity-high {
  border-left-color: var(--high);
  background: var(--high-bg);
}

.finding-card.severity-medium {
  border-left-color: var(--medium);
  background: var(--medium-bg);
}

.finding-card.severity-low {
  border-left-color: var(--low);
  background: var(--low-bg);
}

.finding-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.severity-badge.badge-highlight {
  background: var(--highlight);
  color: var(--white);
}

.severity-badge.badge-critical {
  background: var(--critical);
  color: var(--white);
}

.severity-badge.badge-high {
  background: var(--high);
  color: var(--white);
}

.severity-badge.badge-medium {
  background: var(--medium);
  color: var(--white);
}

.severity-badge.badge-low {
  background: var(--low);
  color: var(--white);
}

.finding-text {
  color: var(--gray-800);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* --- Results Footer --- */
.results-footer {
  margin-top: 32px;
  text-align: center;
}

/* --- Error --- */
.error-section {
  padding: 40px 0 60px;
  animation: fadeIn 0.4s ease;
}

.error-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.error-card h2 {
  color: var(--critical);
  margin-bottom: 12px;
}

.error-card p {
  color: var(--gray-500);
  margin-bottom: 24px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--navy);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Footer --- */
.footer {
  margin-top: auto;
  padding: 24px 0;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.85rem;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.finding-card {
  animation: fadeIn 0.3s ease backwards;
}

.finding-card:nth-child(1) { animation-delay: 0.05s; }
.finding-card:nth-child(2) { animation-delay: 0.1s; }
.finding-card:nth-child(3) { animation-delay: 0.15s; }
.finding-card:nth-child(4) { animation-delay: 0.2s; }
.finding-card:nth-child(5) { animation-delay: 0.25s; }
.finding-card:nth-child(6) { animation-delay: 0.3s; }
.finding-card:nth-child(7) { animation-delay: 0.35s; }
.finding-card:nth-child(8) { animation-delay: 0.4s; }
.finding-card:nth-child(9) { animation-delay: 0.45s; }
.finding-card:nth-child(10) { animation-delay: 0.5s; }
.finding-card:nth-child(11) { animation-delay: 0.55s; }
.finding-card:nth-child(12) { animation-delay: 0.6s; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .hero {
    padding: 40px 0 28px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero-sub {
    font-size: 0.95rem;
  }

  .input-group {
    flex-direction: column;
    border-radius: var(--radius);
  }

  .input-group input {
    padding: 14px 16px;
  }

  .input-group button {
    justify-content: center;
    padding: 14px;
    border-radius: 0;
  }

  .results-header {
    flex-direction: column;
  }

  .results-actions {
    width: 100%;
  }

  .btn-secondary {
    flex: 1;
    justify-content: center;
    font-size: 0.8rem;
    padding: 10px 12px;
  }

  .finding-card {
    padding: 16px 18px;
  }

  .header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
