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

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --gray: #94a3b8;
  --nav-bg: #0f172a;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.topnav {
  background: var(--nav-bg);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topnav-inner {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; opacity: 0.9; }
.nav-right { display: flex; gap: 16px; align-items: center; }
.nav-link { color: #94a3b8; font-size: 13px; }
.nav-link:hover { color: #fff; text-decoration: none; }

/* Main */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 22px; }
.header-actions { display: flex; gap: 8px; }

/* Section */
.section { margin-bottom: 32px; }
.section h2 { font-size: 16px; margin-bottom: 12px; }

/* Summary cards */
.summary-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  flex: 1;
  min-width: 120px;
  text-align: center;
  border-top: 3px solid var(--border);
}
.card .count { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; }
.card .label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.card-critical { border-top-color: var(--red); }
.card-critical .count { color: var(--red); }
.card-high { border-top-color: var(--orange); }
.card-high .count { color: var(--orange); }
.card-medium { border-top-color: var(--yellow); }
.card-medium .count { color: var(--yellow); }
.card-low { border-top-color: var(--gray); }
.card-low .count { color: var(--gray); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--red); border-color: var(--red); background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 12px 24px; font-size: 15px; }

/* Score badge */
.score-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-completed { background: #dcfce7; color: #166534; }
.status-running { background: #dbeafe; color: #1e40af; }
.status-failed { background: #fef2f2; color: #b91c1c; }
.status-pending { background: #f1f5f9; color: #64748b; }

/* Severity badge */
.severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.severity-critical { background: #fef2f2; color: #b91c1c; }
.severity-high { background: #fff7ed; color: #c2410c; }
.severity-medium { background: #fefce8; color: #a16207; }
.severity-low { background: #f1f5f9; color: #64748b; }

/* Status dots */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.dot.gray { background: var(--gray); }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
thead { background: #f8fafc; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
td {
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.table-scroll { overflow-x: auto; }
.table-controls { margin-bottom: 12px; }
.url-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 12px; }
.title-cell { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Score overview */
.score-overview {
  display: flex;
  gap: 32px;
  margin-bottom: 32px;
  align-items: center;
  flex-wrap: wrap;
}
.score-gauge-wrap {
  position: relative;
  width: 200px;
  height: 120px;
}
.gauge-label {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.gauge-score { display: block; font-size: 36px; font-weight: 800; line-height: 1; }
.gauge-text { display: block; font-size: 13px; color: var(--muted); }
.score-radar-wrap { flex: 1; min-width: 300px; max-width: 400px; }

/* Progress */
.crawl-progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.progress-bar-wrap {
  background: #e2e8f0;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar {
  background: var(--primary);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.progress-url {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: monospace;
  font-size: 11px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Form */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 700px;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.form-help { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.search-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card);
  width: 300px;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}

/* Text colors */
.text-red { color: var(--red); font-weight: 600; }
.text-yellow { color: var(--yellow); font-weight: 600; }
.text-green { color: var(--green); font-weight: 600; }
.muted { color: var(--muted); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Login */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin-bottom: 32px; }
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: box-shadow .2s;
}
.google-btn:hover { box-shadow: 0 1px 6px rgba(0,0,0,.1); text-decoration: none; }
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
}
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Action cards */
.actions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  border-left: 4px solid var(--border);
}
.action-high { border-left-color: var(--orange); }
.action-medium { border-left-color: var(--yellow); }
.action-low { border-left-color: var(--gray); }
.action-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.impact-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.impact-high { background: #fff7ed; color: #c2410c; }
.impact-medium { background: #fefce8; color: #a16207; }
.impact-low { background: #f1f5f9; color: #64748b; }
.action-category { font-size: 11px; color: var(--muted); }
.action-card h3 { font-size: 14px; margin-bottom: 6px; }
.action-card p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.affected-urls { margin-top: 10px; }
.affected-urls summary {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}
.affected-urls ul {
  list-style: none;
  margin-top: 6px;
  padding: 0;
}
.affected-urls li {
  font-family: monospace;
  font-size: 11px;
  padding: 2px 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Client styles */
.client-link { font-size: 12px; }
.client-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 13px;
}
.meta-item strong { color: var(--text); }

/* Textarea */
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  resize: vertical;
}
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}

/* Checkbox */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
  main { padding: 16px; }
  .summary-cards { gap: 8px; }
  .card { padding: 12px; min-width: 70px; }
  .card .count { font-size: 20px; }
  .form-row { flex-direction: column; gap: 0; }
  .score-overview { flex-direction: column; align-items: stretch; }
  .score-gauge-wrap { margin: 0 auto; }
  .search-input { width: 100%; }
  table { font-size: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
