:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --ink: #182426;
  --muted: #607174;
  --line: #d8e2df;
  --brand: #116b79;
  --brand-soft: #dff0f2;
  --good: #1f7a55;
  --good-soft: #e0f2e8;
  --warn: #97691c;
  --warn-soft: #fff0d0;
  --danger: #aa3e38;
  --danger-soft: #f9e2df;
  --violet: #5b5a91;
  --shadow: 0 14px 36px rgba(28, 42, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

button, select {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

button {
  padding: 0 14px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(.96);
}

button:focus-visible, select:focus-visible, .run-card:focus-visible {
  outline: 3px solid #f0b36d;
  outline-offset: 2px;
}

button.secondary {
  background: #fff;
  color: var(--brand);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

select {
  width: 168px;
  padding: 0 12px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(26px, 3.5vw, 38px); letter-spacing: 0; }
h2 { margin-bottom: 6px; font-size: 17px; letter-spacing: 0; }
h3 { margin-bottom: 6px; font-size: 14px; letter-spacing: 0; }
p, span, li, dt, dd { line-height: 1.5; }

.topbar, main {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 0 12px;
}

.tagline {
  margin-bottom: 0;
  max-width: 700px;
  color: var(--muted);
  font-size: 14px;
}

.locator {
  margin-bottom: 7px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.locator.small {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.live-badge, .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.live-badge::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(31, 122, 85, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 122, 85, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(31, 122, 85, 0); }
}

.lang-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.lang-toggle button {
  min-height: 30px;
  width: auto;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.lang-toggle button.active {
  background: var(--brand);
  color: #fff;
}

main {
  display: grid;
  gap: 12px;
  padding-bottom: 36px;
}

.mission-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mission-strip > div, .proof-card, .metric, .panel, .subpanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mission-strip > div {
  min-height: 68px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.mission-strip strong {
  display: block;
  max-width: 330px;
  font-size: 15px;
  line-height: 1.35;
}

.proof-strip {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 8px;
}

.proof-card {
  min-height: 68px;
  padding: 11px 14px;
  background: #fbfdfc;
}

.proof-card.live {
  border-color: #83c2a2;
  background: #edf8f3;
}

.proof-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  line-height: 1.35;
}

.proof-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric {
  padding: 10px 14px;
}

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

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

.panel-head.compact {
  align-items: center;
}

.panel-head.compact p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.run-list {
  display: grid;
  gap: 9px;
}

.run-card {
  width: 100%;
  min-height: 78px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  text-align: left;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}

.run-card:hover {
  border-color: #9db9b2;
  background: #f7fbf9;
}

.run-card.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 4px 0 0 var(--brand);
}

.run-card h3 {
  margin-bottom: 4px;
  font-size: 13px;
}

.run-card p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.mini-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 14px;
  margin-bottom: 14px;
}

.plain {
  margin-bottom: 12px;
  color: var(--muted);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-chip.good { background: var(--good-soft); color: var(--good); border-color: #b8dec8; }
.status-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: #efd492; }
.status-chip.danger { background: var(--danger-soft); color: var(--danger); border-color: #efb7b1; }
.status-chip.violet { background: #ebeafd; color: var(--violet); border-color: #d4d2f7; }
.status-chip.neutral { color: var(--muted); }

.decision-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.decision-box h3 {
  font-size: 16px;
}

.decision-box p {
  color: var(--muted);
  font-size: 13px;
}

.button-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.subpanel {
  padding: 14px;
}

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

.evidence-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.evidence-item strong {
  color: var(--ink);
  font-size: 12px;
}

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

.guard-bar {
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef3f1;
}

.guard-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), var(--warn), var(--danger));
}

.guard-facts {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.guard-facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.guard-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.guard-facts dd {
  margin: 0;
  color: var(--ink);
  text-align: right;
  font-size: 12px;
  font-weight: 900;
}

.qwen-panel {
  background: #fbfdfc;
}

#draftBtn {
  min-width: 112px;
  white-space: nowrap;
}

pre {
  min-height: 168px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #162123;
  color: #e7f6f0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.action-log {
  display: grid;
  gap: 9px;
}

.log-entry {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

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

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

.review-path {
  padding: 12px 14px;
}

.path-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  counter-reset: step;
}

.path-steps > span {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.path-steps > span:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  z-index: 1;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  font-style: normal;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .run-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .log-panel {
    order: 3;
  }
}

@media (max-width: 760px) {
  .topbar, main {
    width: min(100vw - 24px, 680px);
  }
  .topbar {
    flex-direction: column;
  }
  .mission-strip, .proof-strip, .metrics, .detail-grid, .columns, .path-steps, .run-list {
    grid-template-columns: 1fr;
  }
  .path-steps > span:not(:last-child)::after {
    display: none;
  }
  .button-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .button-row button {
    font-size: 12px;
    padding: 0 8px;
    white-space: nowrap;
  }
  select {
    width: 100%;
  }
  .panel-head {
    flex-direction: column;
  }
}
