:root {
  color: #0b1f39;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-synthesis: none;
  --brand: #bd241a;
  --brand-dark: #991c14;
  --ink: #0a1c34;
  --muted: #607087;
  --line: #d7dde4;
  --line-strong: #c4ccd5;
  --surface: #ffffff;
  --surface-soft: #f4f6f8;
  --green: #21845f;
  --amber: #b85b08;
  --red: #c92c28;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #edf0f2;
}

button,
select,
input {
  font: inherit;
}

button {
  letter-spacing: 0;
}

.app-shell {
  position: relative;
  width: calc(100% - 28px);
  min-height: calc(100vh - 36px);
  margin: 18px auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid #d2d8df;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(20, 31, 45, 0.05);
}

.app-header {
  min-height: 128px;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}

.brand,
.brand-row,
.header-actions,
.settings-header,
.pane-header,
.file-card,
.rule-tags {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 20px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  object-fit: contain;
  border-radius: 8px;
}

.brand-copy,
.file-copy {
  min-width: 0;
}

.brand-row {
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 34px;
  line-height: 1.2;
  font-weight: 800;
  white-space: nowrap;
}

.brand-row p {
  color: var(--muted);
  font-size: 17px;
  white-space: nowrap;
}

.brand-divider {
  width: 1px;
  height: 34px;
  background: var(--line-strong);
}

.header-actions {
  flex: 0 0 auto;
  gap: 12px;
}

.button {
  height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:focus-visible,
.stat:focus-visible,
.file-card:focus-within,
select:focus-visible {
  outline: 3px solid rgba(189, 36, 26, 0.2);
  outline-offset: 2px;
}

.button:disabled {
  color: #939aa3;
  background: #f7f8f9;
  border-color: #dce1e6;
  cursor: not-allowed;
}

.button-secondary {
  color: #34465b;
  background: #fff;
  border-color: var(--line);
}

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

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

.button:not(:disabled):hover {
  filter: brightness(0.96);
}

.button-icon {
  display: inline-flex;
  width: 22px;
  justify-content: center;
  margin-right: 6px;
  font-size: 23px;
  line-height: 1;
}

.play-icon {
  font-size: 15px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 160px;
  padding: 22px 30px;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.stat {
  position: relative;
  min-width: 0;
  padding: 28px 30px 28px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-left: 6px solid var(--line-strong);
  cursor: pointer;
  text-align: left;
}

.stat::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: transparent;
  transition: background-color 140ms ease;
}

.stat > * {
  position: relative;
  z-index: 1;
}

.stat:hover::after,
.stat.is-active::after {
  background: #f1f3f5;
}

.stat-total {
  border-left-color: #7f8790;
}

.stat-matched {
  border-left-color: var(--green);
}

.stat-review {
  border-left-color: var(--amber);
}

.stat-no-need {
  border-left-color: var(--red);
}

.stat-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #607087;
  font-size: 16px;
  line-height: 1.35;
}

.stat-label span {
  display: block;
}

.stat strong {
  font-size: 44px;
  line-height: 1;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(360px, 3fr);
  min-height: 610px;
}

.results-pane,
.settings-pane {
  min-width: 0;
}

.results-pane {
  border-right: 1px solid var(--line);
}

.pane-header,
.settings-header {
  min-height: 106px;
  padding: 22px 28px;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

h2 {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 800;
}

.pane-header p,
.settings-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

.result-meta {
  color: #718095;
  font-size: 14px;
  text-align: right;
}

.offline-badge {
  flex: 0 0 auto;
  padding: 7px 12px;
  color: #177351;
  background: #eaf5ef;
  border: 1px solid #bddcca;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  position: relative;
  height: 504px;
  overflow: auto;
  background: #fff;
}

table {
  width: 100%;
  min-width: 1480px;
  border-collapse: separate;
  border-spacing: 0;
  color: #243447;
  font-size: 13px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 4;
}

th {
  height: 52px;
  padding: 0 14px;
  color: #344354;
  background: #f0f2f4;
  border-bottom: 1px solid var(--line-strong);
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 750;
}

td {
  min-height: 50px;
  max-width: 270px;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e9ed;
  vertical-align: middle;
  line-height: 1.45;
  word-break: break-word;
}

tbody tr:hover td {
  background: #fafbfc;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
}

td.sticky-col {
  z-index: 2;
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-flex;
  min-width: 70px;
  min-height: 28px;
  padding: 5px 9px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.status-matched {
  color: #166c4b;
  background: #e6f4ed;
}

.status-review {
  color: #99500d;
  background: #fff1df;
}

.status-unmatched {
  color: #a52220;
  background: #fde9e8;
}

.status-skipped {
  color: #536274;
  background: #edf0f3;
}

.doc-cell {
  color: #163f6d;
  font-weight: 700;
}

.empty-state {
  position: absolute;
  inset: 52px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #768395;
  pointer-events: none;
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  font-size: 42px;
  line-height: 1;
  color: #a0aab5;
}

.settings-content {
  padding: 24px;
}

.file-card {
  width: 100%;
  min-height: 102px;
  margin-bottom: 14px;
  padding: 16px;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.file-card:hover {
  background: #fbfcfd;
  border-color: #b6c0ca;
}

.file-card.is-loaded {
  border-color: #8dbca8;
  background: #fbfefc;
}

.file-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-index {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  background: #f9e8e6;
  border-radius: 8px;
  font-size: 19px;
  font-weight: 800;
}

.file-copy {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-action {
  flex: 0 0 auto;
  color: var(--brand);
  font-weight: 700;
  white-space: nowrap;
}

.field-group {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.field-group label,
.rule-label {
  color: #5d6d80;
  font-size: 14px;
}

select {
  width: 100%;
  height: 50px;
  padding: 0 40px 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  cursor: pointer;
}

select:disabled {
  color: #9aa3ad;
  background: #f4f6f7;
  cursor: not-allowed;
}

.rule-summary {
  margin-top: 24px;
  padding-top: 20px;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid #e3e7eb;
}

.rule-tags {
  flex-wrap: wrap;
  gap: 8px;
}

.rule-tags span {
  padding: 6px 9px;
  color: #37556e;
  background: #edf3f7;
  border: 1px solid #d4e0e8;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 30px;
  bottom: 28px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 18px;
  color: #fff;
  background: #12263d;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(9, 24, 41, 0.2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: #a8221e;
}

@media (max-width: 1180px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .button {
    flex: 1 1 0;
  }

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

  .results-pane {
    border-right: 0;
  }

  .settings-pane {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .app-header {
    min-height: 0;
    padding: 20px 16px;
    gap: 20px;
  }

  .brand {
    gap: 13px;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
    flex-basis: 58px;
  }

  .brand-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  h1 {
    font-size: 24px;
    white-space: normal;
  }

  .brand-row p {
    font-size: 13px;
    white-space: normal;
  }

  .brand-divider {
    display: none;
  }

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

  .button {
    min-width: 0;
    height: 46px;
    padding: 0 7px;
    font-size: 13px;
  }

  .button-icon {
    display: none;
  }

  .stats {
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    gap: 8px;
  }

  .stat {
    min-height: 82px;
    padding: 15px 14px 15px 17px;
    border-left-width: 4px;
  }

  .stat-label {
    font-size: 13px;
  }

  .stat strong {
    font-size: 29px;
  }

  .pane-header,
  .settings-header {
    min-height: 88px;
    padding: 18px 16px;
  }

  h2 {
    font-size: 19px;
  }

  .pane-header p,
  .settings-header p {
    font-size: 13px;
  }

  .result-meta {
    display: none;
  }

  .table-wrap {
    height: 470px;
  }

  .settings-content {
    padding: 16px;
  }

  .file-card {
    min-height: 88px;
    padding: 13px;
    gap: 10px;
  }

  .file-index {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .file-action {
    font-size: 13px;
  }

  .field-group,
  .rule-summary {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}

/* Unified desktop scale: matches the production instruction converter. */
@media (min-width: 761px) {
  body {
    background: #eef0f2;
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
  }

  .app-shell {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    width: calc(100% - 24px);
    height: calc(100vh - 24px);
    min-height: calc(100vh - 24px);
    margin: 12px auto;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(17, 24, 32, 0.04);
  }

  .app-header {
    min-height: 86px;
    gap: 24px;
    padding: 16px 28px;
  }

  .brand {
    gap: 14px;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    border-radius: 8px;
  }

  .brand-row {
    gap: 10px;
  }

  h1 {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 750;
  }

  .brand-row p {
    font-size: 13px;
  }

  .brand-divider {
    height: 18px;
  }

  .header-actions {
    gap: 10px;
  }

  .button {
    height: 40px;
    min-width: 96px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
  }

  .button-icon {
    width: 18px;
    margin-right: 4px;
    font-size: 20px;
  }

  .play-icon {
    font-size: 13px;
  }

  .stats {
    min-height: 104px;
    gap: 8px;
    padding: 12px 28px;
  }

  .stat {
    min-height: 76px;
    gap: 10px;
    padding: 10px 18px;
    border-left-width: 3px;
  }

  .stat-label {
    font-size: 14px;
  }

  .stat strong {
    font-size: 30px;
    font-weight: 700;
  }

  .workspace {
    min-height: 0;
    grid-template-columns: minmax(0, 2.15fr) minmax(340px, 0.85fr);
  }

  .results-pane,
  .settings-pane {
    min-height: 0;
  }

  .results-pane {
    display: flex;
    flex-direction: column;
  }

  .pane-header,
  .settings-header {
    min-height: 58px;
    gap: 16px;
    padding: 8px 20px;
  }

  h2 {
    font-size: 16px;
    line-height: 1.35;
    font-weight: 750;
  }

  .pane-header p,
  .settings-header p {
    margin-top: 3px;
    font-size: 12px;
  }

  .result-meta {
    font-size: 12px;
  }

  .offline-badge {
    padding: 4px 8px;
    font-size: 11px;
  }

  .table-wrap {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
  }

  th {
    height: 46px;
    padding: 0 12px;
    font-size: 13px;
  }

  td {
    min-height: 48px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .settings-pane {
    overflow: auto;
  }

  .settings-content {
    padding: 16px 20px 20px;
  }

  .file-card {
    min-height: 76px;
    margin-bottom: 12px;
    gap: 11px;
    padding: 12px;
    border-radius: 8px;
  }

  .file-index {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 6px;
    font-size: 15px;
  }

  .file-copy {
    gap: 5px;
  }

  .file-copy strong {
    font-size: 13px;
  }

  .file-copy span,
  .field-group label,
  .rule-label {
    font-size: 12px;
  }

  .field-group {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    margin-top: 12px;
  }

  select {
    height: 38px;
    padding: 0 32px 0 10px;
    border-radius: 6px;
  }

  .rule-summary {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
  }
}
