:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #18202a;
  --muted: #667085;
  --line: #d9dee8;
  --blue: #2563eb;
  --green: #14804a;
  --green-bg: #e9f7ef;
  --amber: #b76e00;
  --amber-bg: #fff4df;
  --red: #c83b3b;
  --red-bg: #fff0f0;
  --slate: #334155;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  justify-content: flex-end;
  color: var(--slate);
  font-weight: 700;
}

.status-dot,
.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.good,
.legend .good {
  background: var(--green);
}

.status-dot.warn,
.legend .warn {
  background: var(--amber);
}

.status-dot.bad,
.legend .bad {
  background: var(--red);
}

.status-dot.pending {
  background: var(--blue);
}

.run-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.run-card,
.health-panel,
.filters,
.results-panel,
.migration-panel,
.task-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.run-card {
  padding: 16px;
}

.card-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

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

.meta-item {
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.meta-value {
  font-weight: 800;
}

.big-number {
  font-size: 34px;
  line-height: 1;
  font-weight: 850;
}

.big-number.danger {
  color: var(--red);
}

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

.migration-panel {
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.migration-copy p {
  margin: 6px 0 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.5;
}

.migration-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.primary-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

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

.portability-item {
  border-left: 3px solid var(--line);
  background: var(--panel-2);
  padding: 9px 10px;
}

.portability-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

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

.health-panel {
  padding: 18px;
  margin-bottom: 16px;
}

.analysis-launcher {
  padding: 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.launcher-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.launcher-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) 1.3fr;
  gap: 14px;
}

.launcher-editor,
.launcher-config {
  min-width: 0;
}

.launcher-editor label,
.launcher-config label {
  display: block;
  color: var(--slate);
  font-size: 13px;
  font-weight: 800;
}

.launcher-editor textarea,
.launcher-config input,
.launcher-config select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.launcher-editor textarea {
  min-height: 156px;
  padding: 10px;
  resize: vertical;
}

.upload-dropzone {
  display: grid;
  gap: 4px;
  min-height: 72px;
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed #aeb8c7;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--slate);
}

.upload-dropzone.dragging {
  border-color: var(--blue);
  background: #eef3ff;
}

.upload-dropzone strong {
  font-size: 13px;
}

.upload-dropzone span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.launcher-config input,
.launcher-config select {
  height: 38px;
}

.auto-asof-card {
  min-height: 62px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.auto-asof-card span,
.auto-asof-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.auto-asof-card strong {
  display: block;
  margin: 3px 0;
  color: var(--text);
  font-size: 16px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.input-status {
  min-height: 34px;
  margin-top: 10px;
  padding: 9px 10px;
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
}

.input-status.good {
  border-left-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}

.input-status.warn {
  border-left-color: var(--amber);
  background: var(--amber-bg);
  color: var(--amber);
}

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

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

.dimension-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.dimension-grid input {
  width: auto;
  height: auto;
  margin: 0;
}

.include-current-control {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-top: 12px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.include-current-control input {
  width: auto;
  height: auto;
  margin: 0;
}

.data-store-status {
  display: grid;
  gap: 8px;
  min-height: 46px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--slate);
}

.store-main {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

.store-main small {
  grid-column: 2;
}

.data-store-status span,
.data-store-status small {
  color: var(--muted);
  font-size: 12px;
}

.store-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.source-health-strip {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

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

.source-family-list,
.source-issue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-family,
.source-issue {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--slate);
  font-size: 12px;
}

.source-family b {
  color: var(--text);
}

.source-family small {
  color: var(--muted);
}

.source-issue.blocked {
  border-color: #fecaca;
  background: #fff1f2;
  color: #9f1239;
}

.source-issue.candidate_missing {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.source-issue.unstable {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.data-store-status.good {
  border-left-color: var(--green);
}

.data-store-status.warn {
  border-left-color: var(--amber);
}

.data-store-status.bad {
  border-left-color: var(--red);
}

.stock-preview {
  min-height: 70px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.preview-head strong {
  color: var(--slate);
}

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

.stock-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #eef3ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 800;
}

.muted-chip {
  background: #eef2f7;
  color: var(--slate);
}

.run-request-output {
  margin-top: 12px;
}

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

.request-summary div,
.job-status {
  border-left: 3px solid var(--line);
  background: var(--panel-2);
  padding: 9px 10px;
}

.request-summary span,
.job-status small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.request-summary strong,
.job-status strong {
  display: block;
  color: var(--slate);
  font-size: 13px;
}

.job-status {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  border-radius: 6px;
}

.job-status span {
  color: var(--slate);
  font-size: 13px;
}

.job-status.ready,
.job-status.running {
  border-left-color: var(--blue);
}

.job-status.done {
  border-left-color: var(--green);
}

.job-status.manual {
  border-left-color: var(--amber);
}

.job-status.failed {
  border-left-color: var(--red);
}

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

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-head.compact {
  padding: 16px 16px 0;
}

.section-head.mini {
  margin-bottom: 10px;
}

.section-head.mini h2 {
  font-size: 16px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.health-card {
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.health-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.health-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  font-size: 13px;
}

.health-row strong {
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.pill.bad {
  color: var(--red);
  background: var(--red-bg);
}

.pill.neutral {
  color: var(--slate);
  background: #eef2f7;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
}

.side-rail {
  position: sticky;
  top: 16px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filters,
.task-panel {
  padding: 16px;
}

.filters label {
  display: block;
  margin-top: 14px;
  color: var(--slate);
  font-size: 13px;
  font-weight: 800;
}

.filters input,
.filters select,
.row-state-select,
.review-editor select,
.review-editor textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.filters input,
.filters select,
.row-state-select,
.review-editor select {
  height: 38px;
}

.review-editor textarea {
  min-height: 96px;
  padding: 9px 10px;
  resize: vertical;
}

.filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.filter-note {
  margin-top: 16px;
  padding: 12px;
  border-radius: 6px;
  background: #eef3ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.45;
}

.results-panel {
  min-width: 0;
  overflow: hidden;
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--slate);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.ghost-button {
  height: 34px;
  padding: 0 12px;
}

.icon-button {
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 390px);
  min-height: 420px;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.score-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.score-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #edf0f5;
  vertical-align: top;
}

.score-table tr {
  cursor: pointer;
}

.score-table tr:hover {
  background: #f8fbff;
}

.score-table tr.selected {
  background: #eef3ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.stock-name {
  font-weight: 850;
}

.stock-code {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.score-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 74px;
}

.score-main {
  font-weight: 850;
}

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

.reason-cell {
  max-width: 420px;
  line-height: 1.45;
}

.method-summary {
  margin-top: 4px;
  color: var(--slate);
  font-size: 13px;
}

.conclusion-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.method-note {
  margin: -2px 0 12px;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.55;
}

.action-cell {
  min-width: 108px;
}

.work-cell {
  min-width: 128px;
}

.note-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--blue);
  vertical-align: middle;
}

.task-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
  margin-bottom: 8px;
}

.task-item div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.task-item p {
  margin: 7px 0 0;
  color: var(--slate);
  font-size: 12px;
  line-height: 1.45;
}

.task-small {
  color: var(--muted) !important;
}

.text-button {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

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

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 680px;
  max-width: 56vw;
  height: 100vh;
  transform: translateX(104%);
  transition: transform 180ms ease;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.detail-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 18px 20px 28px;
  overflow: auto;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.drawer-tabs {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 0 0 12px;
  background: #fff;
}

.tab-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--slate);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.tab-button.active {
  border-color: #bfdbfe;
  background: #eef3ff;
  color: #1e3a8a;
}

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

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

.metric {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 9px;
  min-height: 58px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 15px;
}

.missing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.evidence-chain {
  line-height: 1.55;
  color: var(--slate);
  margin: 0;
}

.decision-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: #eef3ff;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 800;
}

.decision-label {
  color: #172554;
  font-size: 15px;
}

.readable-conclusion {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.readable-conclusion div {
  min-height: 82px;
  padding: 10px;
  border: 1px solid #dbe5f4;
  border-radius: 6px;
  background: #f8fbff;
}

.readable-conclusion span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.readable-conclusion strong {
  color: var(--slate);
  font-size: 13px;
  line-height: 1.45;
}

.method-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.method-block > div {
  background: var(--panel-2);
  border: 1px solid #edf0f5;
  border-radius: 6px;
  padding: 10px;
}

.method-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--slate);
}

.method-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.48;
}

.method-block li + li {
  margin-top: 4px;
}

.review-editor {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
}

.review-editor label {
  color: var(--slate);
  font-size: 13px;
  font-weight: 800;
}

.review-editor button {
  grid-column: 1 / -1;
  justify-self: start;
}

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

.evidence-link {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--slate);
  text-decoration: none;
  background: var(--panel-2);
}

.evidence-link strong {
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
}

.raw-json {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
}
