:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --ink: #172026;
  --muted: #5e6970;
  --line: #d7dedb;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #9a5b00;
  --amber-soft: #fff7e6;
  --green: #0f6b4f;
  --green-soft: #e9f7f1;
  --blue: #155eef;
  --blue-soft: #eef4ff;
  --charcoal: #263238;
  --focus: #111827;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(21, 94, 239, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 107, 79, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.workspace,
.topbar,
.topbar > *,
.input-panel,
.output-panel,
.priority-board,
.priority-board > *,
.workflow-panel,
.ranked-panel,
.ranked-item,
.output-card,
.detail-panel,
.timeline-panel,
.sources-panel,
label,
.metrics,
.metric,
.kv div,
.workflow-steps li,
.source-item {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

button,
input,
select {
  font: inherit;
}

.workspace {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  max-width: 1580px;
  margin: 0 auto 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span,
.small-tag,
.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  max-width: 1580px;
  margin: 0 auto;
}

.input-panel,
.output-panel {
  min-width: 0;
}

.input-panel {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--focus);
}

.problem-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.segmented label,
.check-grid label,
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  cursor: pointer;
}

.segmented input,
.check-grid input,
.checkbox-line input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--green);
}

.segmented label:has(input:checked),
.check-grid label:has(input:checked),
.checkbox-line:has(input:checked) {
  border-color: var(--green);
  background: var(--green-soft);
  color: #083f30;
}

.field-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

summary {
  cursor: pointer;
  font-weight: 800;
  margin-bottom: 12px;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.input-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input-grid input,
.input-grid select {
  width: 100%;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.unit-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(84px, 0.45fr);
  gap: 6px;
  align-items: stretch;
}

.unit-field select {
  padding-right: 6px;
}

.input-grid input:focus,
.input-grid select:focus,
.icon-button:focus {
  outline: 2px solid rgba(21, 94, 239, 0.28);
  outline-offset: 1px;
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  color: var(--ink) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.priority-board,
.workflow-panel,
.ranked-panel,
.timeline-panel,
.sources-panel,
.detail-panel,
.output-card,
.error-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.priority-board {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: start;
  padding: 20px;
  border-left: 6px solid var(--green);
}

.priority-board h2 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.priority-board p {
  color: var(--muted);
  line-height: 1.6;
}

.workflow-panel {
  margin-top: 12px;
  padding: 16px;
}

.ranked-panel {
  margin-top: 12px;
  padding: 16px;
}

.workflow-panel .panel-head {
  margin-bottom: 12px;
}

.workflow-panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.workflow-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.workflow-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.workflow-steps li {
  min-height: 110px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.workflow-steps li.done {
  border-color: #b7dec8;
  background: var(--green-soft);
}

.workflow-steps li.pending {
  border-color: #ffd7a8;
  background: var(--amber-soft);
}

.workflow-steps li.skip {
  color: var(--muted);
  background: #f2f4f4;
}

.workflow-steps strong,
.workflow-steps span,
.workflow-steps small {
  display: block;
}

.workflow-steps strong {
  font-size: 0.86rem;
  line-height: 1.35;
}

.workflow-steps em {
  display: inline-flex;
  margin-left: 6px;
  font-style: normal;
  color: var(--muted);
  font-size: 0.72rem;
}

.workflow-steps span,
.workflow-steps small,
.workflow-next {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.workflow-steps small {
  margin-top: 6px;
  color: #765100;
  font-weight: 800;
}

.workflow-next {
  margin: 0;
  font-weight: 800;
}

.workflow-confirm {
  margin-top: 10px;
  max-width: max-content;
}

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

.ranked-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.ranked-item.likelihood-high {
  border-top: 5px solid var(--red);
}

.ranked-item.likelihood-medium {
  border-top: 5px solid var(--amber);
}

.ranked-item.likelihood-low {
  border-top: 5px solid var(--blue);
}

.ranked-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.rank-number {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--charcoal);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.ranked-head strong {
  flex: 1 1 160px;
}

.ranked-head em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.ranked-item p,
.ranked-item small {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.ranked-item small {
  margin-top: 8px;
  color: var(--ink);
  font-weight: 800;
}

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

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

.metric strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.metric span {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-break: anywhere;
}

.error-strip {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-color: #ffc9c3;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.output-card {
  padding: 16px;
  min-height: 230px;
}

.output-card.danger {
  border-top: 5px solid var(--red);
}

.output-card.review {
  border-top: 5px solid var(--amber);
}

.output-card.candidate {
  border-top: 5px solid var(--green);
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin-bottom: 8px;
  line-height: 1.48;
}

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

.detail-panel {
  padding: 16px;
}

.detail-panel h3 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.kv {
  display: grid;
  gap: 8px;
}

.kv div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.kv b {
  display: block;
  margin-bottom: 5px;
}

.score-reference span {
  display: block;
  margin-top: 8px;
  line-height: 1.55;
}

.score-reference strong {
  display: inline-block;
  margin-right: 6px;
  color: var(--blue);
}

.timeline-panel,
.sources-panel {
  margin-top: 12px;
  padding: 16px;
}

.review-delta-panel {
  margin-bottom: 12px;
  padding: 16px;
}

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

.comparison-grid > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.comparison-grid b,
.comparison-grid span {
  display: block;
}

.comparison-grid b {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.comparison-grid span {
  line-height: 1.5;
}

.more-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.time-slice {
  min-width: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.time-slice h3 {
  color: var(--blue);
}

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

.transparency-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.transparency-grid > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.transparency-grid b,
.module-audit strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: var(--ink);
}

.transparency-grid p,
.module-audit small {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.tag-row span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #765100;
  font-size: 0.78rem;
  font-weight: 800;
}

.module-audit,
.boundary-list {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding-left: 18px;
}

.module-audit li,
.boundary-list li {
  line-height: 1.55;
}

.module-audit span {
  display: block;
  color: var(--ink);
}

.source-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.source-item a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.source-item a:hover {
  text-decoration: underline;
}

.disclaimer {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #593500;
  font-weight: 800;
}

.empty {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .layout,
  .priority-board {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
    max-height: none;
  }

  .three-column,
  .deep-grid,
  .workflow-steps,
  .ranked-list,
  .comparison-grid,
  .transparency-grid,
  .source-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) and (max-width: 1180px) {
  .workflow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 10px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 12px;
  }

  .topbar > div {
    min-width: 0;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .status-strip span {
    white-space: normal;
  }

  .output-panel {
    order: -1;
  }

  .layout,
  .priority-board,
  .workflow-panel,
  .review-delta-panel,
  .ranked-panel,
  .topbar {
    width: 100%;
    max-width: 100%;
  }

  .priority-board {
    padding: 14px 10px;
    border-left-width: 4px;
  }

  h1,
  .priority-board h2 {
    font-size: 22px;
  }

  .input-grid,
  .check-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .unit-field {
    grid-template-columns: minmax(0, 1fr) minmax(76px, 0.42fr);
  }

  .metric {
    padding: 9px;
  }

  .metric span {
    font-size: 11px;
  }

  .eyebrow,
  .metric span,
  .workflow-panel,
  .ranked-panel,
  .priority-board p {
    overflow-wrap: anywhere;
    word-break: break-all;
    line-break: anywhere;
  }

  .panel-head {
    flex-wrap: wrap;
  }
}
