:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #61706a;
  --line: #d7dfdc;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --accent: #176b52;
  --accent-dark: #0e4f3b;
  --info: #2167a5;
  --warning: #9a6100;
  --danger: #b42318;
  --success-bg: #eaf6f0;
  --warning-bg: #fff7e5;
  --danger-bg: #fff0ee;
  --radius: 6px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { flex: none; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { color: var(--muted); font-size: 13px; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.intro-band {
  background: #e8efec;
  border-bottom: 1px solid var(--line);
  padding: 44px 0;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 48px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 12px; font-size: 34px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { margin-bottom: 2px; font-size: 17px; }
.intro-copy { max-width: 760px; margin-bottom: 0; color: #46534f; }

.primary-button, .secondary-button {
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 700;
}

.primary-button {
  min-width: 156px;
  padding: 0 24px;
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
}
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }

.secondary-button {
  padding: 0 16px;
  border: 1px solid #aebbb6;
  color: var(--ink);
  background: var(--surface);
}
.secondary-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }

.context-band { padding: 28px 0; background: var(--surface); border-bottom: 1px solid var(--line); }
.context-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 20px; }
.environment-item { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.environment-item-wide { grid-column: span 1; }
.environment-item > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.environment-item strong { min-height: 42px; display: flex; align-items: center; font-size: 14px; overflow-wrap: anywhere; }
.environment-item small { margin-top: -5px; color: var(--muted); font-size: 11px; }
.environment-item strong[data-state="warning"] { color: var(--warning); }
.environment-item strong[data-state="success"] { color: var(--accent-dark); }

.test-band, .download-band, .report-band { padding: 38px 0; }
.test-band { background: var(--canvas); }
.download-band { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.report-band { background: #edf2f0; }

.section-heading, .report-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.endpoint-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.endpoint-card {
  min-height: 170px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.endpoint-title-row { display: flex; align-items: flex-start; gap: 12px; }
.endpoint-title-row p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.status-mark { width: 12px; height: 12px; margin-top: 6px; border: 2px solid #9ba8a3; border-radius: 50%; flex: none; }
.endpoint-result { display: flex; flex-direction: column; gap: 4px; }
.result-label { font-size: 15px; }
.result-detail { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.endpoint-card[data-state="running"] { border-color: #80a9c8; }
.endpoint-card[data-state="running"] .status-mark { border-color: var(--info); animation: pulse 1s infinite; }
.endpoint-card[data-state="success"] { border-color: #81b7a3; background: var(--success-bg); }
.endpoint-card[data-state="success"] .status-mark { border-color: var(--accent); background: var(--accent); }
.endpoint-card[data-state="failed"] { border-color: #e2a29c; background: var(--danger-bg); }
.endpoint-card[data-state="failed"] .status-mark { border-color: var(--danger); background: var(--danger); }

@keyframes pulse { 50% { opacity: .35; } }

.download-layout { min-height: 190px; }
.progress-track { height: 12px; overflow: hidden; border: 1px solid #c6d0cc; border-radius: 4px; background: #e7ecea; }
.progress-bar { width: 0; height: 100%; background: var(--info); transition: width .2s ease; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 20px; }
.metric-grid div { padding-top: 12px; border-top: 2px solid #d7dfdc; }
.metric-grid span, .metric-grid strong { display: block; }
.metric-grid span { color: var(--muted); font-size: 12px; }
.metric-grid strong { margin-top: 4px; font-size: 18px; }

.report-layout { border-top: 4px solid #aab8b2; padding-top: 22px; }
.report-band[data-state="success"] .report-layout { border-color: var(--accent); }
.report-band[data-state="warning"] .report-layout { border-color: var(--warning); }
.report-band[data-state="failed"] .report-layout { border-color: var(--danger); }
.report-header { align-items: flex-start; }
.report-header p:last-child { margin: 8px 0 0; color: var(--muted); }
.report-actions { display: flex; gap: 10px; }
.report-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.report-rows div { min-height: 68px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.report-rows div:nth-child(odd) { border-right: 1px solid var(--line); }
.report-rows div:nth-last-child(-n+2) { border-bottom: 0; }
.report-rows span, .report-rows strong { display: block; }
.report-rows span { color: var(--muted); font-size: 12px; }
.report-rows strong { margin-top: 3px; overflow-wrap: anywhere; }

.probe-frames { position: fixed; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.probe-frames iframe { width: 1px; height: 1px; border: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #26312d;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 1120px); }
  .topbar-inner { min-height: 64px; }
  .privacy-note { display: none; }
  .intro-band { padding: 30px 0; }
  .intro-grid { grid-template-columns: 1fr; gap: 22px; }
  h1 { font-size: 27px; }
  .primary-button { width: 100%; }
  .context-grid, .endpoint-grid, .metric-grid, .report-rows { grid-template-columns: 1fr; }
  .section-heading, .report-header { align-items: flex-start; flex-direction: column; gap: 12px; }
  .report-actions { width: 100%; }
  .report-actions button { flex: 1; }
  .report-band { padding: 18px 0; }
  .report-layout { border-top-width: 3px; padding-top: 12px; }
  .report-header { gap: 8px; }
  .report-header h2 { font-size: 18px; }
  .report-header p:last-child { margin-top: 3px; font-size: 10px; }
  .report-actions { gap: 8px; }
  .report-actions button { padding: 8px 10px; font-size: 12px; }
  .report-rows div, .report-rows div:nth-child(odd), .report-rows div:nth-last-child(-n+2) {
    min-height: 0;
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 7px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .report-rows span { font-size: 10px; }
  .report-rows strong { margin-top: 0; font-size: 12px; line-height: 1.3; }
  .report-rows div:last-child { border-bottom: 0; }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .context-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .topbar, .intro-band, .context-band, .test-band, .download-band, .report-actions, .toast { display: none !important; }
  body, .report-band { background: #fff; }
  .report-band { padding: 0; }
  .shell { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
