:root {
  color-scheme: light;
  --page: #eef1f4;
  --surface: #ffffff;
  --surface-muted: #f6f7f9;
  --border: #d8dde3;
  --text: #17202a;
  --muted: #68727d;
  --blue: #1769e0;
  --blue-dark: #0d4fae;
  --green: #17824b;
  --green-soft: #e8f5ee;
  --amber: #9a5a00;
  --amber-soft: #fff5df;
  --red: #c52828;
  --red-soft: #fdecec;
  --shadow: 0 2px 10px rgba(31, 42, 55, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.workspace {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topbar,
.upload-band,
.job-status,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 22px;
}

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

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
}

h2 {
  margin: 0;
  font-size: 19px;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.service-status {
  min-width: 158px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #8b949e;
}

.service-status[data-state="ready"] {
  color: var(--green);
}

.service-status[data-state="ready"] .status-dot {
  background: var(--green);
}

.service-status[data-state="warning"] {
  color: var(--amber);
}

.service-status[data-state="warning"] .status-dot {
  background: var(--amber);
}

.service-status[data-state="error"] {
  color: var(--red);
}

.service-status[data-state="error"] .status-dot {
  background: var(--red);
}

.upload-band,
.job-status,
.result-panel {
  margin-top: 14px;
}

.upload-band {
  padding: 18px 22px 22px;
}

.section-heading,
.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-banner {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin: 18px 22px 0;
  border: 1px solid #b8c7d8;
  border-radius: 5px;
  background: #edf4fc;
  padding: 14px 16px;
}

.result-banner[data-tone="success"] {
  border-color: #a9d8be;
  background: var(--green-soft);
}

.result-banner[data-tone="danger"] {
  border-color: #efb7b7;
  background: var(--red-soft);
}

.result-banner[data-tone="warning"] {
  border-color: #e5c06f;
  background: var(--amber-soft);
}

.result-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
}

.result-banner[data-tone="success"] .result-mark {
  background: var(--green);
}

.result-banner[data-tone="danger"] .result-mark {
  background: var(--red);
}

.result-banner[data-tone="warning"] .result-mark {
  background: var(--amber);
}

.result-banner strong {
  display: block;
  margin-top: 1px;
  font-size: 17px;
}

.result-banner p {
  margin: 5px 0 0;
  color: #394653;
  font-size: 14px;
  line-height: 1.55;
}

.result-banner .qualification-notice {
  color: var(--muted);
  font-size: 13px;
}

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

#upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(190px, 0.9fr) minmax(260px, 1.5fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 16px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field > span {
  color: #3d4650;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #bdc5ce;
  border-radius: 4px;
  background: #fff;
  padding: 8px 11px;
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.13);
}

.field-file input {
  padding: 5px 7px;
}

.field-file input::file-selector-button {
  height: 28px;
  margin-right: 10px;
  border: 1px solid #b8c0ca;
  border-radius: 4px;
  background: var(--surface-muted);
  color: #303943;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button-secondary {
  border-color: #b9c1ca;
  background: #fff;
  color: #26313c;
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

.job-status {
  padding: 17px 22px;
}

.job-status > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.state-badge,
.action-state {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 3px;
  padding: 3px 8px;
  background: #e9edf2;
  color: #48525d;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.state-badge[data-state="completed"],
.action-state[data-state="completed"] {
  background: var(--green-soft);
  color: var(--green);
}

.state-badge[data-state="queued"],
.state-badge[data-state="processing"] {
  background: #e8f0fc;
  color: var(--blue-dark);
}

.state-badge[data-state="failed"],
.action-state[data-state="failed"] {
  background: var(--red-soft);
  color: var(--red);
}

.action-state[data-state="evidence_insufficient"] {
  background: var(--amber-soft);
  color: var(--amber);
}

.progress-track {
  height: 7px;
  overflow: hidden;
  margin-top: 14px;
  border-radius: 3px;
  background: #e7ebef;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 180ms ease;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 13px;
}

.job-meta b {
  color: var(--text);
}

.result-panel {
  padding-bottom: 22px;
}

.final-result {
  margin: 18px 22px 0;
  border: 1px solid #aeb7c1;
  border-left: 4px solid var(--blue);
  background: #f5f8fb;
  padding: 14px 16px;
}

.final-result-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.final-result strong {
  display: block;
  font-size: 18px;
}

.final-result p:not(.final-result-label) {
  margin: 7px 0 0;
  line-height: 1.5;
}

.final-result-next-action {
  color: var(--muted);
  font-size: 13px;
}

.final-result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 10px 0 0;
}

.final-result-meta div {
  min-width: 0;
}

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

.final-result-meta dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .final-result-meta {
    grid-template-columns: 1fr;
  }
}

.final-result[data-decision="pass"] {
  border-color: #a9d8be;
  border-left-color: var(--green);
  background: var(--green-soft);
}

.final-result[data-decision="review"] {
  border-color: #e5c06f;
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.final-result[data-decision="fail"],
.final-result[data-decision="system_error"] {
  border-color: #e7a3a3;
  border-left-color: var(--red);
  background: var(--red-soft);
}

.official-decision-notice {
  margin: 18px 22px 0;
  border: 1px solid #b8c7d8;
  border-left: 4px solid var(--blue);
  background: #edf4fc;
  padding: 12px 16px;
  color: #273847;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

.result-summary {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.verdict-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.verdict-grid > div {
  min-height: 84px;
  padding: 17px 22px;
  border-right: 1px solid var(--border);
}

.verdict-grid > div:last-child {
  border-right: 0;
}

.verdict-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.verdict-grid strong {
  font-size: 20px;
}

.verdict-grid .official-score-card {
  background: #edf4fc;
}

.verdict-grid .official-score-card strong {
  color: var(--blue-dark);
}

.verdict-grid small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.score-breakdown,
.evidence-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.score-breakdown > div,
.evidence-breakdown > div {
  min-height: 62px;
  padding: 12px 22px;
  border-right: 1px solid var(--border);
}

.score-breakdown > div:last-child,
.evidence-breakdown > div:last-child {
  border-right: 0;
}

.score-breakdown span,
.evidence-breakdown span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-breakdown strong,
.evidence-breakdown strong {
  font-size: 16px;
}

#result-analysis-version[data-state="historical-version"] {
  color: var(--amber);
}

#result-analysis-version[data-state="current-version"] {
  color: var(--green);
}

#result-label[data-decision="pass"] {
  color: var(--green);
}

#result-label[data-decision="fail"],
#result-label[data-decision="system_error"] {
  color: var(--red);
}

#result-label[data-decision="review"] {
  color: var(--amber);
}

.failure-section,
.evidence-summary,
.action-section {
  margin: 18px 22px 0;
}

.evidence-summary {
  border: 1px solid #e5c06f;
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
  padding: 14px 16px;
}

.evidence-summary[data-decision="pass"] {
  border-color: #a9d8be;
  border-left-color: var(--green);
  background: var(--green-soft);
}

.evidence-summary-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.evidence-summary-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.evidence-summary-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  flex: 0 0 22px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.evidence-summary[data-decision="pass"] .evidence-summary-icon {
  background: var(--green);
}

.evidence-summary ul {
  margin: 12px 0 0 32px;
  padding: 0;
  list-style: none;
}

.evidence-summary li {
  display: grid;
  gap: 3px;
}

.evidence-summary li + li {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(154, 90, 0, 0.2);
}

.evidence-summary li span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.failure-section {
  border-left: 4px solid var(--red);
  background: var(--red-soft);
  padding: 14px 16px;
}

.failure-section ul {
  margin: 9px 0 0;
  padding-left: 20px;
}

.failure-section li + li {
  margin-top: 6px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: var(--surface-muted);
  color: #3d4650;
  font-weight: 800;
}

th:nth-child(1) {
  width: 17%;
}

th:nth-child(2),
th:nth-child(3),
th:nth-child(4),
th:nth-child(5) {
  width: 12%;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100% - 40px));
  border: 1px solid #aeb7c1;
  border-radius: 5px;
  background: #1f2933;
  box-shadow: var(--shadow);
  padding: 11px 14px;
  color: #fff;
  font-size: 14px;
}

.toast[data-state="error"] {
  border-color: var(--red);
  background: #7d1b1b;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  #upload-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  .workspace {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .service-status {
    min-width: 0;
    justify-content: flex-start;
  }

  #upload-form {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

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

  .verdict-grid > div:nth-child(2) {
    border-right: 0;
  }

  .score-breakdown > div:nth-child(2),
  .evidence-breakdown > div:nth-child(2) {
    border-right: 0;
  }

  .verdict-grid > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .score-breakdown > div:nth-child(-n + 2),
  .evidence-breakdown > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 430px) {
  .topbar,
  .upload-band,
  .job-status,
  .result-summary {
    padding-left: 15px;
    padding-right: 15px;
  }

  h1 {
    font-size: 22px;
  }

  .result-summary {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .score-breakdown,
  .evidence-breakdown {
    grid-template-columns: minmax(0, 1fr);
  }

  .verdict-grid > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .score-breakdown > div,
  .evidence-breakdown > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .failure-section,
  .evidence-summary,
  .action-section,
  .result-banner {
    margin-left: 15px;
    margin-right: 15px;
  }
}
