:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657184;
  --line: #d8e0ea;
  --blue: #1d4ed8;
  --blue-soft: #e2ebff;
  --green: #0f8b67;
  --green-soft: #dcf7ea;
  --amber: #b77912;
  --amber-soft: #fff0cf;
  --red: #b45256;
  --red-soft: #ffe5e7;
  --slate: #475569;
  --slate-soft: #e8eef5;
  --teal: #0f9f8f;
  --shadow: 0 18px 42px rgba(27, 39, 63, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #1d4ed8, #0f9f8f 52%, #d58a19);
  font-weight: 900;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-copy h1 {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.08;
}

.brand-copy p:last-child {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  gap: 9px;
  padding: 0 16px;
  color: #ffffff;
  background: #172033;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(23, 32, 51, 0.18);
}

.primary-button.accent {
  background: #0f8b67;
}

.ghost-button {
  width: 42px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid #ffffff;
}

.reel-icon {
  width: 15px;
  height: 15px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.reset-icon {
  position: relative;
  width: 17px;
  height: 17px;
  border: 2px solid #243044;
  border-right-color: transparent;
  border-radius: 50%;
}

.reset-icon::after {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-top: 2px solid #243044;
  border-right: 2px solid #243044;
  content: "";
  transform: rotate(20deg);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 288px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 16px;
  min-height: calc(100vh - 118px);
  padding: 16px;
}

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

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pill.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.pill.green {
  color: var(--green);
  background: var(--green-soft);
}

.pill.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.pill.slate {
  color: var(--slate);
  background: var(--slate-soft);
}

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

.metric {
  min-height: 68px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1;
}

.filter-stack {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.filter-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
}

.filter-button.active,
.filter-button:hover {
  border-color: rgba(29, 78, 216, 0.45);
  background: #f4f8ff;
}

.filter-button span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.repo-strip {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.repo-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 9px;
  align-items: center;
  min-height: 32px;
  color: #3d4a5d;
  font-size: 12px;
}

.repo-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repo-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.repo-color.c0 {
  background: #1d4ed8;
}

.repo-color.c1 {
  background: #0f9f8f;
}

.repo-color.c2 {
  background: #d58a19;
}

.repo-color.c3 {
  background: #b45256;
}

.repo-color.c4 {
  background: #6750a4;
}

.repo-color.c5 {
  background: #166534;
}

.repo-color.c6 {
  background: #334155;
}

.repo-color.c7 {
  background: #c2410c;
}

.stage-stack {
  display: grid;
  gap: 16px;
}

.hero-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 16px;
  min-height: 356px;
  padding: 16px;
}

.stage-copy {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 8px 8px 8px 4px;
}

.stage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stage-repo {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-copy h2 {
  margin-top: 18px;
  max-width: 780px;
  font-size: 42px;
  line-height: 1.03;
}

.stage-copy p {
  margin-top: 14px;
  max-width: 760px;
  color: #435066;
  font-size: 17px;
  line-height: 1.48;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #354154;
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.signal-panel {
  display: grid;
  align-items: stretch;
  min-height: 320px;
}

#signalCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 16px;
}

.evidence-panel,
.run-panel,
.board-panel {
  padding: 16px;
}

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

.fact-card {
  min-height: 150px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.fact-card.problem {
  border-top: 4px solid var(--red);
}

.fact-card.fix {
  border-top: 4px solid var(--blue);
}

.fact-card.verify {
  border-top: 4px solid var(--green);
}

.fact-card span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.fact-card p {
  color: #293244;
  font-size: 14px;
  line-height: 1.44;
}

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

.file-item {
  overflow: hidden;
  min-height: 34px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  background: #f8fbff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1d4ed8, #0f9f8f, #d58a19);
  transition: width 360ms ease;
}

#progressText {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.step-card {
  min-height: 92px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  transition:
    border 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.step-card.active {
  border-color: rgba(29, 78, 216, 0.55);
  background: #eef5ff;
  transform: translateY(-2px);
}

.step-card.done {
  border-color: rgba(15, 139, 103, 0.48);
  background: #f0fbf5;
}

.step-index {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  border-radius: 50%;
  color: #ffffff;
  background: #243044;
  font-size: 12px;
  font-weight: 900;
}

.step-card.done .step-index {
  background: var(--green);
}

.step-card.active .step-index {
  background: var(--blue);
}

.step-card strong {
  display: block;
  font-size: 12px;
}

.step-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.28;
}

.terminal {
  display: grid;
  grid-template-rows: 30px 1fr;
  min-height: 252px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

.terminal-bar span:nth-child(2) {
  background: #f59e0b;
}

.terminal-bar span:nth-child(3) {
  background: #22c55e;
}

#terminalLog {
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.work-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.work-card {
  display: grid;
  align-content: start;
  min-height: 176px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  text-align: left;
  transition:
    border 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.work-card:hover,
.work-card.active {
  border-color: rgba(29, 78, 216, 0.45);
  background: #f3f8ff;
  transform: translateY(-1px);
}

.work-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.score {
  display: grid;
  place-items: center;
  width: 38px;
  height: 30px;
  border-radius: 8px;
  color: #ffffff;
  background: #172033;
  font-size: 14px;
  font-weight: 900;
}

.mini-pill {
  overflow: hidden;
  max-width: 130px;
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--slate);
  background: var(--slate-soft);
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-card strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.24;
}

.work-repo,
.work-branch {
  display: block;
  overflow: hidden;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-branch {
  margin-top: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 600;
}

@media (max-width: 1280px) {
  .hero-stage,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

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

  .case-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .brand-block,
  .top-actions,
  .hero-stage,
  .repo-strip,
  .file-list,
  .work-board {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    gap: 8px;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .brand-copy h1 {
    font-size: 22px;
  }

  .stage-copy h2 {
    font-size: 29px;
  }

  .stage-copy p {
    font-size: 15px;
  }

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