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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #1a1a2e;
}

h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
  color: #1a1a2e;
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Form */
.form-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
}

.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.btn {
  display: inline-block;
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

/* Tables */
.section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

th {
  font-weight: 600;
  color: #6b7280;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Score badges */
.score {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 40px;
  text-align: center;
}

.score-green {
  background: #dcfce7;
  color: #166534;
}

.score-amber {
  background: #fef3c7;
  color: #92400e;
}

.score-red {
  background: #fee2e2;
  color: #991b1b;
}

.score-na {
  background: #f3f4f6;
  color: #9ca3af;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pending {
  background: #f3f4f6;
  color: #6b7280;
}

.status-crawling {
  background: #dbeafe;
  color: #1e40af;
}

.status-analysing {
  background: #ede9fe;
  color: #5b21b6;
}

.status-complete {
  background: #dcfce7;
  color: #166534;
}

.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* Score cards */
.score-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.score-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.score-card .label {
  font-size: 0.8rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.score-card .value {
  font-size: 2rem;
  font-weight: 700;
}

/* Check results */
.check-list {
  list-style: none;
}

.check-item {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.check-item:last-child {
  border-bottom: none;
}

.check-status {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 58px;
  text-align: center;
}

.check-pass { background: #dcfce7; color: #166534; }
.check-warning { background: #fef3c7; color: #92400e; }
.check-fail { background: #fee2e2; color: #991b1b; }

.check-details {
  font-size: 0.9rem;
}

.check-details .name {
  font-weight: 600;
}

.check-details .desc {
  color: #6b7280;
}

.check-details .rec {
  color: #2563eb;
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Executive Summary / TL;DR */
.tldr-section {
  border-left: 5px solid #2563eb;
  background: linear-gradient(135deg, #f0f7ff 0%, #fff 100%);
}

.tldr-section h2 {
  color: #1e40af;
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.tldr-verdict {
  font-size: 1rem;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.tldr-verdict-good {
  background: #dcfce7;
  color: #166534;
}

.tldr-verdict-mixed {
  background: #fef3c7;
  color: #78350f;
}

.tldr-verdict-poor {
  background: #fee2e2;
  color: #991b1b;
}

.tldr-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.tldr-column {
  border-radius: 8px;
  padding: 14px 16px;
}

.tldr-column h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.tldr-good {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.tldr-good h3 {
  color: #166534;
}

.tldr-bad {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.tldr-bad h3 {
  color: #991b1b;
}

.tldr-column ul {
  list-style: none;
  padding: 0;
}

.tldr-column ul li {
  position: relative;
  padding: 4px 0 4px 20px;
  font-size: 0.88rem;
  color: #374151;
  line-height: 1.5;
}

.tldr-good ul li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: #16a34a;
  font-weight: 700;
}

.tldr-bad ul li::before {
  content: '\2717';
  position: absolute;
  left: 0;
  color: #dc2626;
  font-weight: 700;
}

.tldr-actions {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px 16px;
}

.tldr-actions h3 {
  font-size: 0.95rem;
  color: #1e40af;
  margin-bottom: 8px;
}

.tldr-actions ol {
  padding-left: 20px;
  margin: 0;
}

.tldr-actions ol li {
  padding: 4px 0;
  font-size: 0.88rem;
  color: #374151;
  line-height: 1.5;
}

.tldr-actions ol li::marker {
  color: #2563eb;
  font-weight: 700;
}

.tldr-cat-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  margin-right: 2px;
}

.tldr-cat-seo {
  background: #dbeafe;
  color: #1e40af;
}

.tldr-cat-aeo {
  background: #ede9fe;
  color: #5b21b6;
}

.tldr-cat-geo {
  background: #d1fae5;
  color: #065f46;
}

@media (max-width: 640px) {
  .tldr-columns {
    grid-template-columns: 1fr;
  }
}

/* Action Plan */
.action-plan-heading {
  font-size: 1rem;
  font-weight: 700;
  margin: 20px 0 10px;
  color: #1a1a2e;
}

.action-plan-heading:first-child {
  margin-top: 0;
}

.quick-wins-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.quick-win {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.88rem;
}

.quick-win .qw-name {
  font-weight: 600;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-win .qw-detail {
  color: #4b5563;
  margin-top: 2px;
}

.category-summary {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.category-summary:last-child {
  border-bottom: none;
}

.cat-score-badge {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 52px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}

.cat-summary-text {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.5;
}

.cat-label {
  font-weight: 700;
  margin-right: 4px;
}

.priority-list-items {
  list-style: none;
}

.priority-item {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.priority-item:last-child {
  border-bottom: none;
}

.priority-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  min-width: 66px;
  text-align: center;
}

.priority-critical {
  background: #fee2e2;
  color: #991b1b;
}

.priority-important {
  background: #fef3c7;
  color: #92400e;
}

.category-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: #f3f4f6;
  color: #6b7280;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
}

.priority-details {
  font-size: 0.88rem;
  flex: 1;
}

.priority-details .name {
  font-weight: 600;
}

.priority-details .rec {
  color: #2563eb;
  font-size: 0.83rem;
  margin-top: 2px;
}

.priority-details .page-count {
  color: #6b7280;
  font-size: 0.8rem;
  margin-top: 1px;
}

/* Expandable page list toggle */
.page-toggle-link {
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  font-size: inherit;
}

.page-toggle-link:hover {
  text-decoration-style: solid;
}

.page-toggle-list {
  display: none;
  list-style: none;
  margin: 6px 0 2px;
  padding: 6px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #374151;
}

.page-toggle-list li {
  padding: 2px 0;
  border-bottom: 1px solid #f3f4f6;
}

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

.page-toggle-wrap.open .page-toggle-list {
  display: block;
}

/* Progress */
.progress-msg {
  font-size: 0.9rem;
  color: #6b7280;
  font-style: italic;
}

/* Meta info */
.meta-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #6b7280;
}

.meta-info strong {
  color: #333;
}

/* Collapsible */
.collapsible-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.collapsible-header::before {
  content: '\25B6';
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.collapsible-header.open::before {
  transform: rotate(90deg);
}

.collapsible-body {
  display: none;
  margin-top: 8px;
}

.collapsible-body.open {
  display: block;
}

/* Raw JSON */
.raw-json {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  max-height: 500px;
  overflow-y: auto;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
}

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 12px; }
  h1 { font-size: 1.4rem; }
  th, td { padding: 6px 8px; font-size: 0.82rem; }
  .score-cards { grid-template-columns: repeat(2, 1fr); }
}
