:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202b;
  --muted: #637083;
  --line: #dfe5ec;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --neutral-soft: #eef1f5;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(22, 32, 43, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, #e7f3f0 0, transparent 32rem),
    radial-gradient(circle at 100% 10%, #eef1fb 0, transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

.page {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.mode-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-neutral { background: var(--neutral-soft); color: var(--muted); }
.badge-static { background: var(--warn-soft); color: var(--warn); }
.badge-live { background: var(--ok-soft); color: var(--ok); }

.mode-note {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.mode-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.button {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 9px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }

.button-ghost {
  background: transparent;
  color: var(--accent);
}

.rerun-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.error {
  margin-bottom: 20px;
  border: 1px solid #f2c4c4;
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-weight: 600;
}

.start-here {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-bottom: 22px;
  border: 1px solid #cfe2de;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(230, 244, 241, 0.95), rgba(255, 255, 255, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.start-here-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.start-here h2 {
  font-size: 20px;
  line-height: 1.25;
}

.start-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.start-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  min-width: 0;
}

.start-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #b7d7d1;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.start-steps strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.start-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.start-steps code {
  border-radius: 4px;
  background: #fff;
  padding: 1px 4px;
  color: var(--ink);
  font-size: 11px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.metric-card .metric-value {
  display: block;
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metric-card .metric-label {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric-card .metric-hint {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}

.layout > * { min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); font-size: 12px; }

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

.ticket-button {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.ticket-button:hover { border-color: #b8c6d6; transform: translateX(2px); }

.ticket-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ticket-id { font-size: 12px; font-weight: 800; color: var(--muted); }

.ticket-text {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.detail-panel { min-height: 600px; }

.ticket-text {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: #f8fbfc;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}

.timeline { display: grid; gap: 10px; }

.stage {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  position: relative;
}

.stage:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 30px;
  bottom: -10px;
  width: 2px;
  background: var(--line);
}

.stage-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--neutral-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
}

.stage-body {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  background: #fff;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-name { font-size: 13px; font-weight: 750; }

.stage-detail {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.metric-chip {
  background: #f3f6f9;
  border-radius: 7px;
  padding: 3px 7px;
  font-size: 11px;
  color: var(--muted);
}

.metric-chip strong { color: var(--ink); font-weight: 750; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-error { background: var(--bad-soft); color: var(--bad); }
.status-empty { background: var(--warn-soft); color: var(--warn); }
.status-degraded { background: var(--warn-soft); color: var(--warn); }
.status-skipped { background: var(--neutral-soft); color: var(--muted); }

.answer {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  background: #fbfcfd;
  font-size: 14px;
}

.answer.is-empty { border-color: #f0c9a8; background: var(--warn-soft); }
.answer.is-ok { border-color: #c7e3d2; background: var(--ok-soft); }

.answer-title {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.answer-text { margin: 0; }

.evidence-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.evidence-table th,
.evidence-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 4px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.evidence-table th { color: var(--muted); font-weight: 700; }
.evidence-table td:first-child { width: 32%; }
.evidence-table td:nth-child(2) { width: 22%; }
.evidence-table td:nth-child(3) { width: 46%; }
.evidence-source { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; line-height: 1.4; }

.raw-json {
  max-height: 360px;
  overflow: auto;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f9fb;
  padding: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.boundaries { margin-top: 16px; }

.boundaries ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.boundaries li { margin-bottom: 7px; }

.provenance { margin-top: 16px; }

.provenance dl {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
  font-size: 12px;
}

.provenance dt { color: var(--muted); font-weight: 700; }
.provenance dd { margin: 0; overflow-wrap: anywhere; }

.footer {
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
}

.footer p {
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .evidence-panel { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .page { width: min(100% - 24px, 760px); padding-top: 24px; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .start-here { grid-template-columns: 1fr; }
  .start-steps { grid-template-columns: 1fr; gap: 12px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  .ticket-panel { order: 1; }
  .detail-panel { order: 2; min-height: auto; }
  .evidence-panel { order: 3; }
  .ticket-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  .ticket-button {
    flex: 0 0 230px;
    scroll-snap-align: start;
  }
}

@media (max-width: 520px) {
  .summary { grid-template-columns: 1fr; }
  .provenance dl { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
}

/* ---------- module evidence console ---------- */
.modules-panel { margin-top: 16px; }
.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.module-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fbfcfd;
  min-width: 0;
}
.module-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.module-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.module-title { margin: 0; font-size: 15px; flex: 1 1 auto; }
.module-status {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.module-status-ok { background: var(--ok-soft); color: var(--ok); }
.module-status-bad { background: var(--bad-soft); color: var(--bad); }
.module-status-warn { background: var(--warn-soft); color: var(--warn); }
.module-status-neutral { background: var(--neutral-soft); color: var(--muted); }
.module-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.metric-chip-bad { background: var(--bad-soft); color: var(--bad); }
.module-list { margin-top: 8px; }
.module-list-title {
  margin: 0 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.module-list ul { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.module-list li { margin-bottom: 4px; overflow-wrap: anywhere; }
.module-source {
  margin: 10px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
@media (max-width: 900px) {
  .module-grid { grid-template-columns: 1fr; }
  .module-actions { justify-content: flex-start; }
}
