:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #16212b;
  --muted: #607080;
  --line: #d9e1e7;
  --accent: #0f7b63;
  --accent-dark: #0b5f4c;
  --danger: #b42318;
  --warn: #aa5a00;
  --ok: #157347;
  --soft: #eef6f3;
  --shadow: 0 14px 34px rgba(21, 37, 52, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

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

.tool-panel {
  max-width: 1380px;
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.subtitle {
  max-width: 860px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.hero-actions a,
.upgrade-box a {
  color: var(--accent-dark);
  font-weight: 800;
}

.privacy-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 14px;
}

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

.input-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 2px dashed #b8c7d2;
  border-radius: 8px;
  background: #fbfdfc;
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone strong,
.dropzone span {
  display: block;
}

.dropzone span {
  margin-top: 5px;
  color: var(--muted);
}

.text-input {
  display: flex;
  min-height: 360px;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  font-weight: 800;
}

.text-input.compact-input {
  min-height: 142px;
  flex: 0 0 auto;
}

.text-input.compact-input textarea {
  min-height: 104px;
  flex: 0 0 auto;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 800;
}

.mode-select select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
  color: var(--text);
  font: inherit;
}

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

.check-scope strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.check-scope div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check-scope span {
  border: 1px solid #c9d8d2;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 260px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #fbfcfd;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

textarea:focus {
  outline: 2px solid rgba(15, 123, 99, 0.18);
  border-color: var(--accent);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 9px;
}

.export-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 9px;
  width: 100%;
  max-width: 100%;
}

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

.diagnosis-controls button {
  grid-column: span 1;
}

button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: center;
  cursor: pointer;
}

.diagnosis-output {
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button.primary:hover {
  background: var(--accent-dark);
}

.result-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 14px;
}

.score-strip {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.score-strip > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.score-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.score-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--soft);
}

.tab-panel {
  display: none;
  min-height: 520px;
  flex: 1;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mapping-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.signals-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.signals-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 12px;
}

.signals-actions button {
  min-height: 36px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfd;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

.table-wrap {
  overflow: auto;
}

.issue-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.issue-toolbar label {
  display: flex;
  width: min(260px, 100%);
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.issue-toolbar select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

th {
  background: #f7faf9;
  font-size: 13px;
}

.severity-error {
  color: var(--danger);
  font-weight: 800;
}

.severity-warning {
  color: var(--warn);
  font-weight: 800;
}

.severity-info {
  color: var(--ok);
  font-weight: 800;
}

.field-key {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.muted-cell {
  color: var(--muted);
}

.mapping-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
}

.status-detected {
  background: #e8f5ee;
  color: var(--ok);
}

.status-missing-required {
  background: #fff0ef;
  color: var(--danger);
}

.status-missing-recommended {
  background: #fff6e8;
  color: var(--warn);
}

.status-missing-optional {
  background: #edf3f7;
  color: var(--muted);
}

#cleanedOutput {
  min-height: 520px;
}

.helper-text {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.5;
}

.export-row {
  margin-top: 12px;
}

.upgrade-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.upgrade-box strong,
.upgrade-box span {
  display: block;
}

.upgrade-box span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

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

.upgrade-actions button {
  min-height: 36px;
}

@media (max-width: 980px) {
  .topbar,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .mapping-summary {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  .signals-summary {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

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

  .score-strip,
  .controls,
  .export-row,
  .summary-cards,
  .mapping-summary,
  .signals-summary {
    grid-template-columns: 1fr;
  }

  .upgrade-box {
    align-items: flex-start;
    flex-direction: column;
  }

  .upgrade-actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 26px;
  }
}
