:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d7dde5;
  --accent: #1f6feb;
  --accent-hover: #1a5fd0;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px 20px 48px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
}

.page-head {
  margin-bottom: 18px;
}

.back-link {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 14px;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

/* ===== 左右两栏：左输入、右输出 ===== */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 650;
}

.panel-title-sub {
  margin: 26px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.panel-title-inline {
  margin: 0;
}

.field {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: 2px solid rgba(31, 111, 235, 0.25);
  border-color: var(--accent);
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  margin-bottom: 0;
  color: var(--text);
}

.inline input {
  margin: 0;
}

.error {
  min-height: 20px;
  margin: 4px 0 12px;
  color: var(--danger);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  height: 38px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #aab4c0;
}

button:disabled {
  color: #9aa3af;
  cursor: not-allowed;
}

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

button.primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

button.primary:disabled {
  border-color: #c7d7f2;
  background: #c7d7f2;
  color: #fff;
}

button.mini {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

/* ===== 结果区 ===== */

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}

.output-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.output-head-print {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  min-height: 240px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  white-space: pre;
}

textarea.small {
  min-height: 88px;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== 打印表 ===== */

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hint.warn {
  color: var(--danger);
}

.notice {
  color: #0f7b5f;
}

.notice:empty {
  display: none;
}

.export-options {
  margin-top: 4px;
}

.export-option {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.export-options .export-option:last-child {
  margin-bottom: 0;
}

.export-option legend {
  font-size: 13px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

table.print {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.print th,
table.print td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

table.print thead th {
  position: sticky;
  top: 0;
  background: #f2f5f9;
  color: var(--muted);
  font-weight: 600;
}

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

table.print th.seq,
table.print td.seq {
  width: 46px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

table.print td.code {
  font-family: Consolas, "Courier New", monospace;
}

table.print .name-cell {
  width: 100%;
  min-width: 150px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
}

table.print .name-cell:hover {
  border-color: var(--line);
}

table.print .name-cell:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

table.print tr.row-missing td {
  background: #fff5f4;
}

table.print tr.row-missing .name-cell {
  border-color: var(--danger);
  background: #fff;
}

/* ===== 窄屏：两栏堆叠 ===== */

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
}

@media (max-width: 560px) {
  body {
    padding: 16px 10px 32px;
  }

  .panel {
    padding: 16px 14px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
