:root {
  --ink: #142229;
  --muted: #65747c;
  --line: #dce4e7;
  --paper: #fff;
  --soft: #f2f6f5;
  --deep: #123840;
  --teal: #087d74;
  --green: #1f7a50;
  --green-soft: #e7f5ed;
  --red: #b33d37;
  --red-soft: #fbecea;
  --amber: #9a6a13;
  --amber-soft: #fff5db;
  --shadow: 0 18px 48px rgba(15, 53, 60, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.report-header {
  color: white;
  background:
    radial-gradient(circle at 82% 10%, rgba(73, 195, 170, 0.2), transparent 30%),
    linear-gradient(135deg, #0f3038, #174d53);
}

.header-inner, main { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.header-inner { padding: 28px 0 34px; }
.back-link { color: rgba(255,255,255,.78); font-size: 14px; text-decoration: none; }
.back-link:hover { color: white; }
.eyebrow { margin-top: 38px; color: #7ee0cf; font-size: 12px; font-weight: 800; letter-spacing: .15em; }
.headline-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-top: 10px; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 60px); letter-spacing: -.04em; line-height: 1.05; }
.headline-row p { max-width: 620px; margin: 14px 0 0; color: rgba(255,255,255,.72); font-size: 16px; }
.overall-badge { flex: 0 0 auto; padding: 10px 15px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; font-size: 14px; font-weight: 800; }
.overall-badge.is-passed { color: #a8f0ce; background: rgba(32,143,97,.2); }
.overall-badge.is-failed { color: #ffc1bd; background: rgba(179,61,55,.2); }
.overall-badge.is-loading { color: rgba(255,255,255,.7); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 30px; }
.summary-card { padding: 17px 18px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; }
.summary-card span { display: block; color: rgba(255,255,255,.64); font-size: 12px; }
.summary-card strong { display: block; margin-top: 6px; font-size: 26px; }
.generated-at { margin: 15px 0 0; color: rgba(255,255,255,.6); font-size: 12px; }

main { padding: 28px 0 60px; }
.controls { position: sticky; top: 12px; z-index: 5; display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 16px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.search-field { flex: 1 1 360px; }
.search-field span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.search-field input { width: 100%; min-height: 42px; padding: 0 13px; color: var(--ink); background: #f8faf9; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.search-field input:focus { outline: 3px solid rgba(8,125,116,.13); border-color: var(--teal); }
.status-filters { display: flex; gap: 7px; flex-wrap: wrap; }
.status-filters button { min-height: 40px; padding: 0 12px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.status-filters button.active { color: white; background: var(--deep); border-color: var(--deep); }

.report-content { margin-top: 26px; }
.category { margin-top: 34px; }
.category:first-child { margin-top: 0; }
.category-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.category-heading h2 { margin: 0; font-size: 21px; }
.category-heading span { color: var(--muted); font-size: 13px; }
.test-list { display: grid; gap: 10px; }
.test-card { display: grid; grid-template-columns: 150px minmax(0,1fr); overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 18px rgba(15,53,60,.04); }
.test-meta { padding: 18px; background: #f8faf9; border-right: 1px solid var(--line); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-passed { color: var(--green); background: var(--green-soft); }
.status-failed, .status-timed_out, .status-interrupted { color: var(--red); background: var(--red-soft); }
.status-never_run, .status-skipped { color: var(--amber); background: var(--amber-soft); }
.test-type { display: block; margin-top: 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
.test-body { padding: 18px 20px; }
.test-title-row { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.test-title { margin: 0; font-size: 16px; line-height: 1.45; }
.last-run { flex: 0 0 auto; color: var(--muted); font-size: 12px; text-align: right; }
.criterion { margin: 13px 0 0; padding: 12px 14px; color: #405159; background: #f5f8f7; border-left: 3px solid #85b9af; border-radius: 0 8px 8px 0; font-size: 14px; line-height: 1.65; }
.criterion strong { color: var(--ink); }
.use-case { margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.use-case summary { padding: 11px 13px; color: var(--deep); font-size: 13px; font-weight: 800; cursor: pointer; }
.use-case summary span { display: inline-block; margin-right: 8px; padding: 3px 7px; color: white; background: var(--teal); border-radius: 5px; font-size: 11px; letter-spacing: .04em; }
.use-case[open] summary { border-bottom: 1px solid var(--line); }
.use-case-grid { display: grid; grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr); gap: 12px; padding: 14px 14px 4px; }
.use-case-grid > div { padding: 10px 12px; background: #f7faf9; border-radius: 8px; }
.use-case-grid strong, .use-case-section > strong { color: var(--deep); font-size: 12px; }
.use-case-grid p { margin: 5px 0 0; color: #405159; font-size: 13px; line-height: 1.55; }
.use-case-section { padding: 9px 15px 3px; }
.use-case-section:last-child { padding-bottom: 13px; }
.use-case-section ul, .use-case-section ol { margin: 7px 0 0; padding-left: 22px; color: #405159; font-size: 13px; line-height: 1.65; }
.source { margin-top: 11px; color: #87939a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.failure { margin: 10px 0 0; color: var(--red); font-size: 13px; line-height: 1.5; }
.empty-state, .error-state { padding: 54px 24px; background: white; border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.empty-state h2, .error-state h2 { margin: 0 0 8px; }
.empty-state p, .error-state p { margin: 0; color: var(--muted); }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 260px; color: var(--muted); }
.loading-state span { width: 8px; height: 8px; background: var(--teal); border-radius: 50%; animation: pulse 1.1s infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: .2s; }
.loading-state span:nth-child(3) { animation-delay: .4s; }
.loading-state p { margin: 0 0 0 8px; }
footer { padding: 22px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; font-size: 12px; }
@keyframes pulse { to { opacity: .25; transform: translateY(-4px); } }

@media (max-width: 760px) {
  .header-inner, main { width: min(100% - 24px, 1160px); }
  .headline-row, .controls { align-items: stretch; flex-direction: column; }
  .overall-badge { align-self: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .controls { position: static; }
  .test-card { grid-template-columns: 1fr; }
  .test-meta { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-right: 0; border-bottom: 1px solid var(--line); }
  .test-type { margin: 0; }
  .test-title-row { flex-direction: column; }
  .last-run { text-align: left; }
  .use-case-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { .loading-state span { animation: none; } }
