:root {
  --bg: #edf2f7;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d6dee8;
  --blue: #1d4ed8;
  --green: #0f8b67;
  --amber: #b77912;
  --red: #b42318;
  --dark: #111827;
  --shadow: 0 18px 44px rgba(23, 32, 51, 0.1);
}

* {
  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,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

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

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

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

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

.brand h1 {
  font-size: 24px;
  line-height: 1.08;
}

.brand 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,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.primary-button {
  gap: 9px;
  padding: 0 15px;
  color: #fff;
  background: var(--dark);
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.16);
}

.primary-button.light {
  background: var(--green);
}

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

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

.play-icon,
.scan-icon {
  display: inline-block;
}

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

.scan-icon {
  width: 15px;
  height: 15px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
}

.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);
}

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

.status.safe {
  color: var(--green);
  background: #dcf7ea;
}

.status.warning {
  color: var(--amber);
  background: #fff0cf;
}

.status.idle {
  color: #475569;
  background: #e8eef5;
}

.status.scanning {
  color: var(--blue);
  background: #e2ebff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(560px, 1fr) minmax(310px, 390px);
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

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

.control-panel,
.review-panel,
.mission-panel,
.pipeline-panel,
.detail-panel {
  padding: 16px;
}

.control-panel,
.review-panel {
  min-height: calc(100vh - 128px);
}

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

.panel-head.tight {
  margin-bottom: 10px;
}

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

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-label {
  display: block;
  margin: 13px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #f8fbff;
}

.safety-block {
  margin-top: 16px;
}

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

.safety-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.safety-item input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--green);
}

.safety-item strong,
.safety-item em {
  display: block;
}

.safety-item strong {
  font-size: 13px;
}

.safety-item em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.terminal {
  display: grid;
  grid-template-rows: 30px 1fr;
  min-height: 276px;
  margin-top: 14px;
  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,
#prBody {
  margin: 0;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

#terminalLog {
  padding: 12px;
  font-size: 12px;
  line-height: 1.52;
}

.center-stack {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.mission-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 16px;
  align-items: stretch;
  min-height: 190px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.case-meta span {
  min-height: 25px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fbff;
  font-size: 12px;
  font-weight: 800;
}

.mission-copy h2 {
  max-width: 760px;
  font-size: 36px;
  line-height: 1.02;
}

.mission-copy p {
  margin-top: 13px;
  color: #334155;
  font-size: 16px;
  line-height: 1.48;
}

.score-dial {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border-radius: 8px;
  color: #fff;
  background: var(--dark);
}

.score-dial span {
  color: #a7b2c3;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.score-dial strong {
  font-size: 46px;
  line-height: 1;
}

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(120px, 240px) 42px;
  align-items: center;
  gap: 8px;
}

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

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green), #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: 9px;
}

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

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

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

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

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

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

.step strong,
.step em {
  display: block;
}

.step strong {
  font-size: 13px;
}

.step em {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.32;
}

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

.fact-block,
.files-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.fact-block {
  min-height: 160px;
  padding: 13px;
}

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

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

.fact-block.command p {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.files-block {
  margin-top: 10px;
  padding: 13px;
}

.files-block ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.files-block li {
  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;
}

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

.issue-card {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 96px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  text-align: left;
}

.issue-card:hover,
.issue-card.active {
  border-color: rgba(29, 78, 216, 0.48);
  background: #f3f8ff;
}

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

.issue-top strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-top b {
  display: grid;
  place-items: center;
  width: 36px;
  height: 28px;
  border-radius: 8px;
  color: #fff;
  background: var(--dark);
  font-size: 13px;
}

.issue-title {
  color: #243044;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.22;
}

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

.pr-preview {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.pr-preview h3 {
  font-size: 18px;
  line-height: 1.18;
}

#prBody {
  min-height: 300px;
  margin-top: 11px;
  padding: 12px;
  border-radius: 8px;
  color: #d1fae5;
  background: #111827;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .review-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

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

  .topbar,
  .brand,
  .top-actions,
  .workspace,
  .mission-panel,
  .triple-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .control-panel,
  .review-panel {
    min-height: auto;
  }

  .top-actions {
    justify-content: stretch;
  }

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

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

  .files-block ul {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .mission-copy h2 {
    font-size: 28px;
  }

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