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

:root {
  --primary: #04243D;
  --primary-dark: #021829;
  --primary-light: #dbeafe;
  --critical: #dc2626;
  --critical-bg: #fef2f2;
  --serious: #ea580c;
  --serious-bg: #fff7ed;
  --moderate: #ca8a04;
  --moderate-bg: #fefce8;
  --minor: #16a34a;
  --minor-bg: #f0fdf4;
  --pass: #15803d;
  --pass-bg: #dcfce7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
.site-header {
  background: #04243D;
  color: white;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-icon { height: 40px; width: auto; max-width: 160px; flex-shrink: 1; }
.header-brand h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.header-sub { display: none; }
.beta-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #FF3511;
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.header-badge { display: flex; gap: 8px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.3);
  color: white;
}
.badge-wcag { background: rgba(255,255,255,.15); }
.badge-nz { background: rgba(255,255,255,.1); }

/* ── Layout ── */
.main-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
}
.card-header svg { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; }

/* ── URL Input ── */
.url-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.url-text-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.url-text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.url-text-input::placeholder { color: var(--text-3); }

/* ── URL List ── */
.url-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  max-height: 220px;
  overflow-y: auto;
}
.url-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-2);
}
.url-item .url-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-remove {
  width: 20px; height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.url-remove:hover { background: var(--critical-bg); color: var(--critical); }
.url-remove svg { width: 14px; height: 14px; }

/* ── Presets ── */
.url-presets { margin-bottom: 14px; }
.preset-label { font-size: 11px; color: var(--text-3); font-weight: 500; display: block; margin-bottom: 6px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Scan Options ── */
.scan-options { margin-bottom: 16px; }
.option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Info card ── */
.info-card { background: #f0f7ff; border-color: #bfdbfe; }
.info-text { font-size: 12px; color: #1e40af; line-height: 1.6; margin-bottom: 12px; }
.wcag-new-badge-list { display: flex; flex-wrap: wrap; gap: 5px; }
.new-label { font-size: 11px; font-weight: 600; color: var(--primary); width: 100%; display: block; margin-bottom: 4px; }
.tag-new {
  font-size: 10px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--text-2);
}
.empty-state svg { width: 80px; height: 80px; margin-bottom: 20px; }
.empty-state h2 { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-2); max-width: 380px; line-height: 1.6; }

/* ── Progress ── */
.progress-section { margin-bottom: 16px; }
.scanning-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.scanning-title { font-size: 15px; font-weight: 600; }
.scanning-url { font-size: 12px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 400px; }
.spinner {
  width: 32px; height: 32px; flex-shrink: 0;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s ease; }
.progress-text { font-size: 12px; color: var(--text-2); }

/* ── Summary grid ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-card.critical { border-left: 3px solid var(--critical); }
.stat-card.serious  { border-left: 3px solid var(--serious); }
.stat-card.moderate { border-left: 3px solid var(--moderate); }
.stat-card.minor    { border-left: 3px solid var(--minor); }
.stat-card.pass     { border-left: 3px solid var(--pass); }
.stat-card.total    { border-left: 3px solid var(--primary); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card.critical .stat-value { color: var(--critical); }
.stat-card.serious  .stat-value { color: var(--serious); }
.stat-card.moderate .stat-value { color: var(--moderate); }
.stat-card.minor    .stat-value { color: var(--minor); }
.stat-card.pass     .stat-value { color: var(--pass); }
.stat-card.total    .stat-value { color: var(--primary); }

/* ── Tabs ── */
.results-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 0;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  border-radius: 4px 4px 0 0;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.export-btn { margin-left: auto; margin-bottom: 1px; }
.tab-content.hidden { display: none; }

/* ── Site result card ── */
.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.site-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background .12s;
}
.site-card-header:hover { background: var(--surface-2); }
.site-card.expanded .site-card-header { border-bottom-color: var(--border); }
.site-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.site-status-dot.ok { background: var(--pass); }
.site-status-dot.warn { background: var(--serious); }
.site-status-dot.fail { background: var(--critical); }
.site-status-dot.error-dot { background: var(--text-3); }
.site-url { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-chips { display: flex; gap: 6px; flex-shrink: 0; }
.impact-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.impact-chip.critical { background: var(--critical-bg); color: var(--critical); }
.impact-chip.serious  { background: var(--serious-bg);  color: var(--serious); }
.impact-chip.moderate { background: var(--moderate-bg); color: var(--moderate); }
.impact-chip.minor    { background: var(--minor-bg);    color: var(--minor); }
.impact-chip.pass     { background: var(--pass-bg);     color: var(--pass); }
.expand-arrow {
  width: 18px; height: 18px;
  color: var(--text-3);
  transition: transform .2s;
  flex-shrink: 0;
}
.site-card.expanded .expand-arrow { transform: rotate(180deg); }

.site-card-body { padding: 16px; }
.site-error { color: var(--critical); font-size: 13px; padding: 8px; background: var(--critical-bg); border-radius: 6px; }

/* ── Violation table ── */
.violation-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.violation-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .4px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.violation-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.violation-table tr:last-child td { border-bottom: none; }
.violation-table tr:hover td { background: var(--surface-2); }
.v-help { font-weight: 500; color: var(--text); }
.v-link { color: var(--primary); text-decoration: none; font-size: 11px; }
.v-link:hover { text-decoration: underline; }

.learn-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 4px 9px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  white-space: nowrap;
  transition: background .12s;
}
.learn-more-btn:hover { background: #dbeafe; }

.impact-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
}
.impact-badge.critical { background: var(--critical-bg); color: var(--critical); }
.impact-badge.serious  { background: var(--serious-bg);  color: var(--serious); }
.impact-badge.moderate { background: var(--moderate-bg); color: var(--moderate); }
.impact-badge.minor    { background: var(--minor-bg);    color: var(--minor); }

.wcag-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin: 2px 2px 0 0;
  border: 1px solid;
}
.wcag-tag.level-A  { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.wcag-tag.level-AA { background: #fdf4ff; color: #7e22ce; border-color: #e9d5ff; }
.wcag-tag.level-AAA { background: #fdf4ff; color: #6b21a8; border-color: #d8b4fe; }
.wcag-tag.new22    { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* ── Criteria view ── */
.criteria-group { margin-bottom: 20px; }
.criteria-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 8px 0;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.principle-icon {
  width: 22px; height: 22px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.criteria-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.criteria-row.is-violated { border-color: #fca5a5; background: #fff5f5; }
.criteria-row.is-new22 { border-color: #fcd34d; }
.criteria-id { font-size: 12px; font-weight: 700; color: var(--primary); min-width: 48px; flex-shrink: 0; }
.criteria-info { flex: 1; min-width: 0; }
.criteria-name { font-weight: 600; font-size: 12px; color: var(--text); }
.criteria-meta { display: flex; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.criteria-level { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.criteria-level.A   { background: #e0f2fe; color: #0369a1; }
.criteria-level.AA  { background: #f3e8ff; color: #7e22ce; }
.criteria-level.AAA { background: #fdf4ff; color: #6b21a8; }
.new22-flag {
  font-size: 9px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #fcd34d;
}
.criteria-sites { font-size: 11px; color: var(--text-2); flex-shrink: 0; text-align: right; min-width: 80px; }
.criteria-sites strong { color: var(--critical); }
.check-icon { color: var(--pass); }
.fail-icon  { color: var(--critical); }

/* ── Overview tab ── */
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.overview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.overview-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { font-size: 11px; color: var(--text-2); min-width: 70px; }
.bar-track { flex: 1; height: 16px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.bar-fill.critical { background: var(--critical); }
.bar-fill.serious  { background: var(--serious); }
.bar-fill.moderate { background: var(--moderate); }
.bar-fill.minor    { background: var(--minor); }
.bar-count { font-size: 11px; font-weight: 600; min-width: 28px; text-align: right; color: var(--text-2); }

.site-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.site-summary-row:last-child { border-bottom: none; }
.site-summary-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.site-summary-count { font-weight: 700; color: var(--critical); }
.site-summary-count.zero { color: var(--pass); }

.hidden { display: none !important; }

@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .logo-icon { height: 28px; }
  .header-inner { height: 56px; }
  .header-brand h1 { font-size: 15px; }
}
