:root {
  --bg: #f7faff;
  --surface: #ffffff;
  --surface-soft: #f0f6ff;
  --line: #dfe8f5;
  --line-strong: #c7d7ef;
  --text: #111827;
  --muted: #64748b;
  --orange: #2463ff;
  --orange-dark: #1455ee;
  --amber: #ff8a00;
  --red: #ff3b48;
  --green: #12b76a;
  --blue: #2463ff;
  --violet: #7c5cff;
  --shadow: 0 16px 34px rgba(28, 68, 138, 0.08);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-soft: #16223a;
  --line: #1f2c44;
  --line-strong: #2e3e5e;
  --text: #e6edf7;
  --muted: #94a3b8;
  --orange: #4f8aff;
  --orange-dark: #3a78ff;
  --amber: #ffb84a;
  --red: #ff6b75;
  --green: #34d399;
  --blue: #4f8aff;
  --violet: #a08cff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top right, rgba(36, 99, 255, 0.08), transparent 36rem),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 58%, #fff 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(36, 99, 255, 0.28);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 14px;
  border-right: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.9);
  backdrop-filter: blur(18px);
}

.sidebar-header {
  display: contents;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: #303846;
  flex-shrink: 0;
}

.nav-toggle .nav-toggle-close,
.sidebar[data-nav-open="true"] .nav-toggle .nav-toggle-open {
  display: none;
}

.sidebar[data-nav-open="true"] .nav-toggle .nav-toggle-close {
  display: block;
}

#currentViewLabel {
  display: none;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: center;
  padding: 0 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #0ea5e9);
  box-shadow: 0 10px 20px rgba(36, 99, 255, 0.22);
}

.brand strong,
.workspace-card strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand small,
.workspace-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 0 17px;
  border-radius: 8px;
  border: 0;
  color: #3b4350;
  background: transparent;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: var(--blue);
  background: #edf4ff;
}

.nav-item svg,
.brand-mark svg,
.icon-btn svg,
.date-pill svg,
.text-btn svg,
.workspace-card svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.workspace-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  margin-top: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #f1f7ff;
  text-align: left;
}

.workspace-card[role="button"] {
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.workspace-card[role="button"]:hover {
  background: #e6f1ff;
  border-color: var(--blue);
}

.workspace-card[role="button"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.workspace-card[role="button"]:active {
  transform: scale(0.99);
}

html {
  scroll-behavior: smooth;
}

#auditHistoryPanel {
  scroll-margin-top: 20px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.avatar svg {
  width: 18px;
  height: 18px;
}

.content {
  min-width: 0;
  padding: 22px 28px 14px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.2vw, 32px);
  line-height: 1.15;
  font-weight: 800;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.download-menu-wrap {
  position: relative;
}

.icon-btn,
.date-pill,
.clear-url {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: #303846;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.download-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  display: grid;
  width: min(270px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.download-menu[hidden] {
  display: none;
}

.download-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #fff;
  transform: rotate(45deg);
}

.download-menu button {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #e7eef8;
  color: #334155;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.download-menu button:last-child {
  border-bottom: 0;
}

.download-menu button:hover,
.download-menu button:focus-visible {
  background: #f5f9ff;
  outline: 0;
}

.download-menu button svg {
  width: 17px;
  height: 17px;
  color: var(--blue);
}

.download-menu button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-menu button em {
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.with-badge span {
  position: absolute;
  top: -4px;
  right: -2px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  color: #fff;
  background: var(--orange);
  font-size: 10px;
  font-weight: 700;
}

.date-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.audit-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.audit-card {
  margin-bottom: 16px;
  padding: 16px;
  min-width: 0;
}

.audit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 112px 112px 148px;
  gap: 16px;
  min-width: 0;
}

.url-field {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.url-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #3b4350;
  background: transparent;
}

.crawl-field {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.crawl-field select {
  width: 52px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0 18px 0 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
  background-size: 14px 14px;
  cursor: pointer;
}

.preset-field {
  grid-template-columns: 1fr 86px;
}

.preset-field select {
  width: 86px;
}

.clear-url {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.run-stop-group {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 20px rgba(36, 99, 255, 0.2);
}

.run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  color: #fff;
  background: linear-gradient(135deg, #2f74ff, #1557ee);
  font-weight: 800;
  flex: 1;
}

.run-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 44px;
  border: 0;
  border-left: 1px solid rgba(255,255,255,0.25);
  border-radius: 0;
  color: rgba(255,255,255,0.7);
  background: linear-gradient(135deg, #2f74ff, #1557ee);
  flex-shrink: 0;
}

.stop-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stop-btn:not(:disabled) {
  color: #fff;
  background: #e8362e;
  border-left-color: rgba(255,255,255,0.2);
}

.audit-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 12px;
}

.scan-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.running {
  background: var(--blue);
  animation: pulse-dot 1s ease-in-out infinite;
}

.status-dot.error {
  background: var(--red);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}

.audit-timing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #d8e6ff;
  border-radius: 8px;
  color: #475569;
  background: #f6f9ff;
  font-size: 12px;
}

.audit-timing[hidden] {
  display: none;
}

.audit-timing span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.audit-timing svg {
  width: 15px;
  height: 15px;
  color: var(--blue);
}

.audit-timing strong {
  color: #1f2937;
  white-space: nowrap;
}

#auditScope {
  justify-content: flex-end;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crawl-log {
  display: grid;
  gap: 6px;
  max-height: 142px;
  overflow: auto;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #d8e6ff;
  border-radius: 8px;
  background: #fbfdff;
}

.crawl-log[hidden] {
  display: none;
}

.crawl-log-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: #475569;
  font-size: 12px;
}

.crawl-log-row strong {
  color: #1f2937;
  font-weight: 800;
}

.crawl-log-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crawl-log-row em {
  min-width: 48px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  text-align: right;
}

.progress-track {
  overflow: hidden;
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e8f0ff;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 280ms ease;
}

.client-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 12px;
}

.client-tools textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: #303846;
  background: #fbfdff;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  outline: 0;
}

.client-tool-actions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #3b4350;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.secondary-btn svg {
  width: 16px;
  height: 16px;
}

.file-btn input,
#htmlFile,
#importHistoryFile {
  display: none;
}

.danger-btn {
  color: #b42318;
  border-color: #ffd5d0;
  background: #fff7f5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1.05fr repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
}

.score-card,
.metric-card {
  min-height: 188px;
}

.score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}

.panel-title,
.metric-card span {
  width: 100%;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.score-ring {
  --score: 86;
  --ring: calc(var(--score) * 1%);
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  width: 134px;
  height: 134px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 58%, transparent 59%),
    conic-gradient(var(--green) 0 var(--ring), #e8eef6 var(--ring) 100%);
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: #fff;
}

.score-ring strong,
.score-ring span,
.score-ring em {
  position: relative;
  z-index: 1;
}

.score-ring strong {
  font-size: 42px;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-size: 15px;
}

.score-ring em {
  margin-top: 5px;
  color: var(--green);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.delta,
.trend-up,
.trend-down {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.delta {
  width: 100%;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.delta svg {
  width: 15px;
  height: 15px;
  padding: 2px;
  border-radius: 50%;
  background: #dff6e9;
  color: var(--green);
}

.delta strong,
.trend-up {
  color: var(--green);
}

.delta.neutral strong {
  color: #475569;
}

.delta.neutral svg {
  color: #64748b;
  background: #e9eef5;
}

.metric-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 18px;
}

.metric-card[role="button"] {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.metric-card[role="button"]:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 30px rgba(28, 68, 138, 0.12);
}

.metric-card[role="button"]:focus-visible {
  outline: 3px solid rgba(36, 99, 255, 0.32);
  outline-offset: 2px;
}

.metric-card[role="button"]:active {
  transform: translateY(0);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.metric-icon svg {
  width: 20px;
  height: 20px;
}

.metric-icon.orange {
  color: var(--blue);
  background: #edf4ff;
}

.metric-icon.red {
  color: var(--red);
  background: #ffebe9;
}

.metric-icon.amber {
  color: var(--amber);
  background: #fff4d7;
}

.metric-icon.green {
  color: var(--green);
  background: #e4f8ee;
}

.metric-icon.blue {
  color: var(--blue);
  background: #eef2ff;
}

.metric-icon.violet {
  color: var(--violet);
  background: #f1eeff;
}

.metric-card strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 28px;
  line-height: 1;
}

.metric-card small {
  font-size: 11px;
  font-weight: 700;
}

.trend-up svg,
.trend-down svg {
  width: 8px;
  height: 8px;
  fill: currentColor;
}

.trend-down {
  color: var(--red);
}

.trend-down svg {
  transform: rotate(180deg);
}

.trend-neutral {
  color: #64748b;
}

.trend-neutral svg {
  width: 10px;
  height: 10px;
}

.sparkline {
  grid-column: 1 / -1;
  align-self: end;
  width: 100%;
  height: 46px;
}

.dashboard-grid,
.bottom-grid,
.workspace-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.diff-panel-wrap {
  margin-bottom: 16px;
}

.diff-panel {
  padding: 16px 18px;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.diff-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  overflow: hidden;
}

.diff-column-head {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.diff-column.resolved .diff-column-head {
  color: var(--green);
  background: #e3f8ed;
}

.diff-column.introduced .diff-column-head {
  color: var(--red);
  background: #ffebe9;
}

.diff-column-head svg {
  width: 16px;
  height: 16px;
}

.diff-column-head strong {
  font-size: 13px;
  font-weight: 800;
  color: inherit;
}

.diff-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}

.diff-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: #334155;
}

.diff-list li:last-child {
  border-bottom: 0;
}

.diff-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-list li em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.diff-list-empty {
  padding: 16px 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px;
}

.vital-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 4px;
}

.vital-card span {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vital-card strong {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.vital-card.good strong {
  color: var(--green);
}

.vital-card.warn strong {
  color: var(--amber);
}

.vital-card.bad strong {
  color: var(--red);
}

.vital-card em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.dashboard-grid {
  grid-template-columns: 1.05fr 1.02fr 1.3fr;
}

.bottom-grid {
  grid-template-columns: 1.08fr 1.12fr;
}

.workspace-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.full-panel {
  min-height: 280px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mini-input {
  width: min(240px, 42vw);
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: #3b4350;
  background: #fff;
  font-size: 12px;
  outline: 0;
}

.issue-panel,
.chart-panel,
.category-panel {
  min-height: 326px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  min-width: 0;
  font-size: 15px;
  line-height: 1.2;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.report-export-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.export-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.export-action-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--blue);
}

.export-action-btn:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.export-action-btn:hover svg {
  color: #fff;
}

.export-action-btn:active {
  opacity: 0.85;
}

.compact-select {
  height: 32px;
  max-width: 152px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.issue-list,
.category-list,
.recent-list {
  display: grid;
}

.issue-row,
.category-row,
.recent-row {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid #e6eef8;
  font-size: 12px;
}

.issue-row {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.issue-row {
  grid-template-columns: 18px minmax(0, 1fr) auto 18px;
}

.issue-row:hover {
  background: #f4f8ff;
}

.issue-row:last-child,
.category-row:last-child,
.recent-row:last-child {
  border-bottom: 0;
}

.issue-row svg,
.category-row svg,
.recent-row svg {
  width: 16px;
  height: 16px;
}

.issue-row span,
.category-row span,
.recent-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.count-pill.red {
  color: var(--red);
  background: #fff0ef;
  border: 1px solid #ffd2ce;
}

.count-pill.amber {
  color: #d56f00;
  background: #fff3df;
  border: 1px solid #ffd59b;
}

.count-pill.blue {
  color: var(--blue);
  background: #eef2ff;
  border: 1px solid #dce4ff;
}

.main-chart {
  width: 100%;
  height: 260px;
  padding: 8px 14px 14px;
}

.history-chart {
  width: 100%;
  height: 160px;
  padding: 8px 14px 0;
}

.category-row {
  grid-template-columns: 20px minmax(130px, 1fr) 58px auto;
}

.category-score {
  color: #46505e;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status-pill.good {
  color: #118552;
  background: #e3f8ed;
}

.status-pill.work {
  color: #c66a00;
  background: #fff3df;
}

.status-pill.none {
  color: #475569;
  background: #edf2f7;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
}

th,
td {
  height: 38px;
  padding: 0 16px;
  border-bottom: 1px solid #e6eef8;
  color: #485160;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 700;
}

td:first-child {
  max-width: 310px;
  overflow: hidden;
  color: #2975e8;
  text-overflow: ellipsis;
}

.health {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 23px;
  border-radius: 8px;
  font-weight: 800;
}

.health.good {
  color: #118552;
  background: #e3f8ed;
}

.health.warn {
  color: #d56f00;
  background: #fff0d5;
}

.health.bad {
  color: #c4312b;
  background: #ffebe9;
}

.recent-row {
  grid-template-columns: 18px minmax(0, 1fr) auto;
}

.recent-row time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

footer {
  padding: 8px 0 0;
  color: #9ca3af;
  font-size: 11px;
  text-align: center;
}

.finding-list,
.history-list,
.settings-list {
  display: grid;
}

.finding-row,
.history-row {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid #e6eef8;
  background: transparent;
  color: inherit;
  text-align: left;
}

.finding-row {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.finding-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.history-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  width: 100%;
}

.history-load,
.history-delete {
  display: grid;
  align-items: center;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.history-load {
  min-width: 0;
}

.history-delete {
  place-items: center;
  width: 34px;
  border-radius: 8px;
  color: var(--muted);
}

.history-delete:hover {
  color: var(--red);
  background: #ffebe9;
}

.history-delete svg {
  width: 16px;
  height: 16px;
}

.history-row:hover {
  background: #f4f8ff;
}

.finding-row strong,
.history-row strong {
  display: block;
  font-size: 13px;
}

.finding-row small,
.history-row small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finding-row small.guidance-text {
  color: #334155;
  white-space: normal;
}

.finding-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.finding-icon svg {
  width: 17px;
  height: 17px;
}

.finding-icon.issue {
  color: var(--red);
  background: #ffebe9;
}

.finding-icon.warning {
  color: var(--amber);
  background: #fff4d7;
}

.finding-icon.info {
  color: var(--blue);
  background: #eef2ff;
}

.priority-pill,
.delta-pill,
.queue-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  text-transform: capitalize;
}

.priority-pill.critical {
  color: #b42318;
  background: #ffebe9;
}

.priority-pill.high {
  color: #c2410c;
  background: #fff0df;
}

.priority-pill.medium {
  color: #1d4ed8;
  background: #eef2ff;
}

.priority-pill.low {
  color: #475569;
  background: #edf2f7;
}

.queue-state.done {
  color: #118552;
  background: #e3f8ed;
}

.queue-state.active {
  color: #1d4ed8;
  background: #eef2ff;
}

.queue-state.failed {
  color: #c4312b;
  background: #ffebe9;
}

.queue-state.skipped,
.queue-state.pending {
  color: #d56f00;
  background: #fff3df;
}

.empty-state {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.padded-grid {
  padding: 14px;
}

.insight-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 138px;
  padding: 18px;
}

.insight-card strong {
  font-size: 24px;
  line-height: 1.1;
}

.insight-card span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-box {
  overflow: auto;
  min-height: 300px;
  margin: 0;
  padding: 16px;
  color: #313947;
  background: #f8fbff;
  font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.recommendation-list {
  display: grid;
}

.recommendation-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 74px;
  padding: 12px 16px;
  border-bottom: 1px solid #e6eef8;
}

.recommendation-row:last-child {
  border-bottom: 0;
}

.recommendation-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--blue);
  background: #eef2ff;
  font-size: 12px;
  font-weight: 800;
}

.recommendation-row strong {
  display: block;
  font-size: 13px;
}

.recommendation-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.recommendation-row .recommendation-samples {
  overflow: hidden;
  color: #334155;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-panel {
  max-width: 760px;
}

.settings-list {
  padding: 10px 16px 16px;
}

.settings-list label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  border-bottom: 1px solid #e6eef8;
  color: #333b48;
  font-size: 13px;
  font-weight: 700;
}

.settings-list label:last-child {
  border-bottom: 0;
}

.settings-list select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.settings-list input[type="number"] {
  width: 150px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: #334155;
  background: #fff;
}

.settings-list input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.pill-track {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #d1dae8;
  transition: background 0.2s;
  position: relative;
}

.pill-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.pill-toggle input:checked + .pill-track {
  background: var(--blue);
}

.pill-toggle input:checked + .pill-track .pill-thumb {
  transform: translateX(18px);
}

.pill-toggle input:focus-visible + .pill-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.report-options,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  align-items: end;
  min-width: 0;
}

.data-actions .domain-delete {
  flex: 1 1 220px;
  min-width: 220px;
}

.report-options {
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr) auto;
  align-items: start;
}

.report-options label,
.domain-delete {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.report-options input[type="text"],
.report-options textarea,
.domain-delete select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: #334155;
  background: #fff;
  font: inherit;
  outline: 0;
}

.report-options textarea {
  min-height: 74px;
  resize: vertical;
  line-height: 1.45;
}

.toggle-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--blue);
}

.advanced-tools {
  margin: 10px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.advanced-tools summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.advanced-tools .client-tools {
  margin: 0;
  padding: 0 12px 12px;
}

.client-tools.in-settings {
  grid-template-columns: minmax(0, 1fr) auto;
}

.privacy-note {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border: 1px solid #d8e6ff;
  border-radius: 8px;
  color: #3f4d63;
  background: #f4f8ff;
  font-size: 12px;
  line-height: 1.45;
}

.link-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.link-result.ok {
  color: #118552;
  background: #e3f8ed;
}

.link-result.bad {
  color: #c4312b;
  background: #ffebe9;
}

.link-chain {
  color: #475569;
  font-size: 11px;
  white-space: normal;
  line-height: 1.45;
}

.link-source {
  display: block;
  max-width: 260px;
  overflow: hidden;
  color: #2563eb;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-source em {
  display: block;
  overflow: hidden;
  color: #64748b;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gap-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid #e6eef8;
}

.gap-summary article,
.canonical-cluster,
.limitations-panel article {
  min-width: 0;
  border: 1px solid #e5edf9;
  border-radius: 8px;
  background: #fbfdff;
}

.gap-summary article {
  padding: 10px;
}

.gap-summary span,
.canonical-cluster small,
.limitations-panel small {
  display: block;
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

.gap-summary strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 20px;
}

.canonical-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.canonical-cluster {
  padding: 12px;
}

.canonical-cluster header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.canonical-cluster strong {
  overflow: hidden;
  color: #0f172a;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canonical-cluster em {
  flex: 0 0 auto;
  color: #2563eb;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.canonical-cluster div {
  display: grid;
  gap: 6px;
}

.canonical-cluster div span {
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.limitations-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.limitations-panel article {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.limitations-panel svg {
  width: 20px;
  height: 20px;
}

.limitations-panel article.ok svg {
  color: var(--green);
}

.limitations-panel article.warn svg {
  color: var(--blue);
}

.limitations-panel strong {
  display: block;
  margin-bottom: 3px;
  color: #0f172a;
  font-size: 13px;
}

.source-pill,
.robots-rule {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  min-height: 24px;
  padding: 0 8px;
  overflow: hidden;
  border-radius: 999px;
  color: #1d4ed8;
  background: #eef6ff;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.robots-rule {
  color: #b45309;
  background: #fff7e8;
}

.page-issue-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.page-issue-card {
  display: grid;
  gap: 9px;
  width: 100%;
  border: 1px solid #e4edf8;
  border-radius: 8px;
  padding: 12px;
  color: inherit;
  background: #fbfdff;
  text-align: left;
}

.page-issue-card:hover,
.page-issue-card:focus-visible {
  border-color: #b8cdf8;
  background: #f5f9ff;
}

.page-issue-head,
.page-issue-meta,
.page-issue-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.page-issue-head {
  justify-content: space-between;
}

.page-issue-head strong {
  min-width: 0;
  overflow: hidden;
  color: #1d4ed8;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-issue-meta {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.issue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.issue-chip.issue {
  color: #b42318;
  background: #fff1f0;
}

.issue-chip.warning {
  color: #b45309;
  background: #fff7e8;
}

.issue-chip small {
  color: inherit;
  opacity: 0.8;
}

.page-row {
  cursor: pointer;
}

.page-row:hover td {
  background: #f5f9ff;
}

.page-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.page-modal.open {
  display: block;
}

.page-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
}

.page-modal-card {
  position: absolute;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(760px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.page-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.close-modal-btn {
  width: 36px;
  height: 36px;
}

.page-modal-body {
  overflow: auto;
  padding: 14px 16px 18px;
}

.page-detail-url {
  margin-bottom: 10px;
  color: #2563eb;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.page-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.page-detail-grid article {
  padding: 10px;
  border: 1px solid #e5edf9;
  border-radius: 8px;
  background: #fbfdff;
}

.page-detail-grid span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.page-detail-grid strong {
  display: block;
  margin-top: 5px;
  color: #0f172a;
  font-size: 16px;
}

.score-breakdown {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.score-breakdown h3 {
  margin: 4px 0 0;
  font-size: 13px;
}

.score-base-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr) auto);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e5edf9;
  border-radius: 8px;
  background: #f8fbff;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.score-base-row strong {
  color: #0f172a;
}

.score-breakdown-list {
  display: grid;
  gap: 8px;
}

.score-summary-panel,
.verification-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.score-summary-head,
.verification-grid,
.related-signal-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-summary-head article,
.verification-grid article,
.related-signal-list span {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e5edf9;
  border-radius: 8px;
  background: #fbfdff;
}

.score-summary-head span,
.related-signal-list small {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.score-summary-head strong,
.related-signal-list strong {
  display: block;
  margin-top: 5px;
  color: #0f172a;
  font-size: 18px;
}

.score-method {
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}

.related-signal-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.related-signal-list span {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.verification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.verification-head strong {
  color: #334155;
  font-size: 13px;
}

.confidence-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #1d4ed8;
  background: #eef2ff;
  font-size: 12px;
  font-weight: 900;
  text-transform: capitalize;
}

.confidence-pill.high {
  color: #118552;
  background: #e3f8ed;
}

.confidence-pill.medium,
.confidence-pill.standard {
  color: #d56f00;
  background: #fff0d5;
}

.confidence-pill.limited {
  color: #475569;
  background: #edf2f7;
}

.verification-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.verification-grid article {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.verification-grid article svg {
  width: 18px;
  height: 18px;
}

.verification-grid article.ok svg {
  color: var(--green);
}

.verification-grid article.warn svg {
  color: var(--amber);
}

.verification-grid span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.verification-grid strong {
  grid-column: 2;
  color: #0f172a;
  font-size: 13px;
}

.verification-notes {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
}

.score-deduction {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e8eef8;
  border-radius: 8px;
  background: #fff;
}

.score-deduction strong,
.score-deduction small {
  display: block;
}

.score-deduction small {
  margin-top: 3px;
  color: #64748b;
  font-size: 11px;
}

.score-deduction em {
  color: #b42318;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.page-detail-findings {
  display: grid;
  gap: 8px;
}

.page-detail-findings h3 {
  margin: 4px 0;
  font-size: 13px;
}

.page-detail-findings .finding-row {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.compare-panel {
  grid-column: 1 / -1;
}

.compare-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e6eef8;
}

.compare-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compare-controls select {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: #334155;
  background: #fff;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.compare-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.compare-card span,
.compare-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compare-card strong {
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.compare-card em {
  width: max-content;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.compare-card.better em {
  color: #087443;
  background: #ddf7ea;
}

.compare-card.worse em {
  color: #c4312b;
  background: #ffebe9;
}

.compare-card.same em {
  color: #475569;
  background: #edf2f7;
}

.delta-pill.better {
  color: #087443;
  background: #ddf7ea;
}

.delta-pill.worse {
  color: #c4312b;
  background: #ffebe9;
}

.delta-pill.same {
  color: #475569;
  background: #edf2f7;
}

.compare-pages {
  padding: 0 16px 16px;
}

.compare-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compare-settings span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfdff;
  font-size: 12px;
}

.compare-settings strong {
  color: var(--text);
  font-size: 12px;
}

.compare-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.compare-page-head h3 {
  margin: 0;
  font-size: 14px;
}

.compare-page-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.change-detail {
  max-width: 360px;
  color: #334155;
  white-space: normal;
  line-height: 1.45;
}

@media (max-width: 1220px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-card {
    grid-column: span 2;
  }

  .dashboard-grid,
  .bottom-grid,
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-summary-head,
  .verification-grid,
  .related-signal-list,
  .gap-summary,
  .limitations-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet: collapse the sidebar earlier so 768-1024px isn't stuck in a half-broken desktop layout */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    gap: 0;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }

  .brand {
    padding: 0;
    flex: 1 1 auto;
    min-width: 0;
  }

  .brand strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #currentViewLabel {
    display: block;
    color: var(--blue);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand small:not(#currentViewLabel) {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    display: none;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 8px;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 253, 255, 0.98);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 30px rgba(28, 68, 138, 0.14);
  }

  .sidebar[data-nav-open="true"] .nav-list {
    display: grid;
  }

  .nav-item {
    grid-template-columns: 22px 1fr;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 8px;
  }

  .workspace-card {
    display: none;
  }

  /* Backdrop when nav is open */
  .sidebar[data-nav-open="true"]::after {
    content: "";
    position: fixed;
    inset: 0;
    top: var(--nav-bottom, 70px);
    z-index: 30;
    background: rgba(15, 23, 42, 0.32);
    pointer-events: auto;
  }

  .content {
    padding: 20px 20px 14px;
  }

  .topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .audit-form {
    grid-template-columns: minmax(0, 1fr) 160px 112px 112px;
  }

  .audit-form .run-stop-group {
    grid-column: span 2;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-card {
    grid-column: span 2;
  }

  .dashboard-grid,
  .bottom-grid,
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .insight-grid,
  .compare-grid,
  .score-summary-head,
  .verification-grid,
  .related-signal-list,
  .gap-summary,
  .limitations-panel,
  .vitals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile: full single-column stack */
@media (max-width: 720px) {
  .content {
    padding: 16px 14px 14px;
  }

  .audit-meta,
  .audit-timing {
    display: grid;
    gap: 6px;
  }

  #auditScope {
    justify-content: flex-start;
    white-space: normal;
  }

  .crawl-log-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .crawl-log-row em {
    text-align: left;
  }

  .audit-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .audit-form .run-stop-group {
    grid-column: auto;
  }

  .client-tools,
  .client-tools.in-settings {
    grid-template-columns: minmax(0, 1fr);
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .score-card {
    grid-column: span 2;
  }

  /* Compact metric cards on mobile: tight padding, smaller numbers, no sparkline/trend */
  .metric-card {
    grid-template-columns: 32px minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 8px;
    padding: 12px;
    min-height: 0;
  }

  .metric-card .metric-icon {
    width: 28px;
    height: 28px;
  }

  .metric-card .metric-icon svg {
    width: 16px;
    height: 16px;
  }

  .metric-card span {
    font-size: 11px;
    line-height: 1.2;
  }

  .metric-card strong {
    margin: 4px 0 0;
    font-size: 22px;
  }

  .metric-card small,
  .metric-card .sparkline {
    display: none;
  }

  .category-row {
    grid-template-columns: 20px minmax(0, 1fr) 54px;
  }

  .category-row .status-pill {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .recent-row {
    grid-template-columns: 18px minmax(0, 1fr);
    padding-block: 10px;
  }

  .recent-row time {
    grid-column: 2;
  }

  .insight-grid,
  .compare-controls,
  .compare-grid,
  .compare-settings,
  .report-options,
  .data-actions,
  .score-base-row,
  .score-summary-head,
  .verification-grid,
  .related-signal-list,
  .gap-summary,
  .limitations-panel,
  .diff-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .mini-input {
    width: 100%;
  }

  .recommendation-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .recommendation-row .finding-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .page-modal-card {
    top: 12px;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }

  .page-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Tables stay scrollable inside their wrapper, never push the page */
  .table-wrap {
    max-width: 100%;
  }

  table {
    min-width: 480px;
  }

  /* Headline sizes shrink on small screens */
  h1 {
    font-size: clamp(20px, 6vw, 26px);
  }
}

@media (max-width: 520px) {
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 12px;
  }

  .date-pill span {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .audit-card {
    padding: 14px;
  }

  .icon-btn,
  .date-pill {
    height: 38px;
  }

  .icon-btn {
    width: 38px;
  }
}

/* Dark mode overrides — applied when <html data-theme="dark"> is set.
   The :root token block above defines the new color values; these rules
   patch surfaces/backgrounds that were hard-coded in light hex. */
[data-theme="dark"] body {
  background:
    radial-gradient(circle at top right, rgba(79, 138, 255, 0.10), transparent 36rem),
    linear-gradient(180deg, #0d1626 0%, var(--bg) 58%, #0a1120 100%);
}

[data-theme="dark"] .audit-card,
[data-theme="dark"] .panel,
[data-theme="dark"] .url-field,
[data-theme="dark"] .crawl-field,
[data-theme="dark"] .toggle-row,
[data-theme="dark"] .download-menu,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .date-pill,
[data-theme="dark"] .clear-url,
[data-theme="dark"] .nav-toggle,
[data-theme="dark"] .vital-card,
[data-theme="dark"] .diff-column {
  background: var(--surface) !important;
  color: var(--text);
}

[data-theme="dark"] .pill-track {
  background: #3a4560;
}

[data-theme="dark"] .sidebar {
  background: rgba(17, 26, 43, 0.92) !important;
}

[data-theme="dark"] .nav-list {
  /* Fully opaque so dimmed page content behind the drawer doesn't bleed through. */
  background: var(--surface) !important;
  backdrop-filter: none !important;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55) !important;
  border-bottom-color: var(--line-strong) !important;
}

[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
  background: var(--surface-soft) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
}

[data-theme="dark"] .settings-list select,
[data-theme="dark"] .settings-list input[type="number"],
[data-theme="dark"] .report-options input[type="text"],
[data-theme="dark"] .report-options textarea,
[data-theme="dark"] .domain-delete select,
[data-theme="dark"] .compare-controls select {
  background: var(--surface-soft) !important;
  color: var(--text) !important;
  border-color: var(--line-strong) !important;
}

[data-theme="dark"] table th,
[data-theme="dark"] table td {
  color: var(--text);
  border-color: var(--line);
}

[data-theme="dark"] .panel-title,
[data-theme="dark"] .panel-head h2,
[data-theme="dark"] .audit-form span,
[data-theme="dark"] .vital-card span,
[data-theme="dark"] .diff-column-head {
  color: var(--text);
}

[data-theme="dark"] .panel-note,
[data-theme="dark"] .audit-meta,
[data-theme="dark"] .crawl-log-row,
[data-theme="dark"] .vital-card em,
[data-theme="dark"] .diff-list li {
  color: var(--muted);
}

[data-theme="dark"] .progress-track {
  background: var(--line);
}

[data-theme="dark"] .crawl-log {
  background: var(--surface-soft);
  border-color: var(--line);
}

[data-theme="dark"] .diff-column.resolved .diff-column-head {
  background: rgba(52, 211, 153, 0.18);
  color: var(--green);
}

[data-theme="dark"] .diff-column.introduced .diff-column-head {
  background: rgba(255, 107, 117, 0.18);
  color: var(--red);
}

[data-theme="dark"] .metric-icon.orange {
  background: rgba(79, 138, 255, 0.18);
}

[data-theme="dark"] .metric-icon.red {
  background: rgba(255, 107, 117, 0.18);
}

[data-theme="dark"] .metric-icon.amber {
  background: rgba(255, 184, 74, 0.18);
}

[data-theme="dark"] .metric-icon.green {
  background: rgba(52, 211, 153, 0.18);
}

[data-theme="dark"] .health.good {
  background: rgba(52, 211, 153, 0.18);
  color: var(--green);
}

[data-theme="dark"] .health.warn {
  background: rgba(255, 184, 74, 0.18);
  color: var(--amber);
}

[data-theme="dark"] .health.bad {
  background: rgba(255, 107, 117, 0.18);
  color: var(--red);
}

/* Dark-mode hover/focus states.
   Light mode uses pale blue/cream backgrounds (#f4f8ff, #f5f9ff, #ffebe9) on hover —
   in dark mode that produces unreadable light-row + light-text combinations.
   Replace with subtle blue tints over the dark surface so text stays legible. */
[data-theme="dark"] .issue-row:hover,
[data-theme="dark"] .history-row:hover,
[data-theme="dark"] .download-menu button:hover,
[data-theme="dark"] .download-menu button:focus-visible,
[data-theme="dark"] .page-issue-card:focus-visible {
  background: rgba(79, 138, 255, 0.12);
  outline: 0;
}

[data-theme="dark"] .nav-item {
  color: var(--text);
}

[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
  background: rgba(79, 138, 255, 0.16) !important;
  color: var(--blue);
}

[data-theme="dark"] .nav-item svg {
  color: var(--muted);
}

[data-theme="dark"] .nav-item:hover svg,
[data-theme="dark"] .nav-item.active svg {
  color: var(--blue);
}

[data-theme="dark"] .page-row:hover td {
  background: rgba(79, 138, 255, 0.12);
}

[data-theme="dark"] .history-delete:hover {
  background: rgba(255, 107, 117, 0.18);
  color: var(--red);
}

[data-theme="dark"] .page-issue-card:focus-visible {
  border-color: rgba(79, 138, 255, 0.45);
}

/* Light status pills used inside rows also need dark-mode tints. */
[data-theme="dark"] .status-pill.none,
[data-theme="dark"] .delta.neutral svg {
  background: rgba(148, 163, 184, 0.18);
  color: var(--muted);
}

/* Audit progress + crawl log + client-tools textarea all use hardcoded light
   backgrounds and dark text — illegible in dark mode. */
[data-theme="dark"] .audit-timing,
[data-theme="dark"] .crawl-log,
[data-theme="dark"] .client-tools textarea {
  background: var(--surface-soft) !important;
  border-color: var(--line) !important;
  color: var(--text);
}

/* Score ring: the gauge has a white inner disk + a light-gray unfilled track,
   both hard-coded. Repaint them with dark tokens in dark mode. */
[data-theme="dark"] .score-ring {
  background:
    radial-gradient(circle, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--green) 0 var(--ring), var(--line) var(--ring) 100%);
}

[data-theme="dark"] .score-ring::after {
  background: var(--surface);
}

[data-theme="dark"] .score-ring strong {
  color: var(--text);
}

[data-theme="dark"] .audit-timing strong,
[data-theme="dark"] .crawl-log-row,
[data-theme="dark"] .crawl-log-row strong {
  color: var(--text);
}

[data-theme="dark"] .crawl-log-row em {
  color: var(--muted);
}
