/* ============ Reset & Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fa;
  color: #1f2329;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
input, select, button, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ============ Layout ============ */
.app { max-width: 720px; margin: 0 auto; padding: 12px 16px 80px; }

.header {
  text-align: center;
  padding: 24px 0 16px;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  color: #1f2329;
}
.subtitle {
  font-size: 13px;
  color: #86909c;
  margin-top: 4px;
}

/* ============ Card ============ */
.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ============ Field ============ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: #4e5969;
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 5l3 3 3-3' stroke='%23c9cdd4' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #165dff;
  box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

/* ============ Items ============ */
.items-section { margin: 20px 0 16px; }
.items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.items-header h3 { font-size: 15px; font-weight: 600; }
.dict-stats {
  font-size: 12px;
  font-weight: normal;
  color: #86909c;
  margin-left: 4px;
}
.dict-stats.loaded { color: #00b42a; }
.dict-stats.error { color: #f53f3f; }

.item-row {
  background: #f7f8fa;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  position: relative;
}
.item-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 90px 32px;
  gap: 8px;
  align-items: center;
}
.item-row-grid input {
  padding: 9px 10px;
  border: 1px solid #e5e6eb;
  border-radius: 6px;
  background: #fff;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}
.item-row-grid input:focus {
  outline: none;
  border-color: #165dff;
}
.item-row-grid input[readonly] {
  background: #f7f8fa;
  color: #4e5969;
  cursor: default;
}
/* 编码命中：绿框 + 浅绿名称 */
.item-row-grid input.matched {
  border-color: #00b42a;
  background: #f0fff4;
}
.item-row-grid input.matched:focus {
  box-shadow: 0 0 0 3px rgba(0, 180, 42, 0.12);
}
/* 编码 / 数量未通过校验：红框 */
.item-row-grid input.unmatched {
  border-color: #f53f3f;
  background: #fff5f5;
}
.item-row .remove-row {
  background: #f53f3f;
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* ============ Buttons ============ */
.btn-primary, .btn-secondary {
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: #165dff;
  color: #fff;
}
.btn-primary:hover { background: #0e42d2; }
.btn-primary:disabled {
  background: #c9cdd4;
  cursor: not-allowed;
}
.btn-secondary {
  background: #f2f3f5;
  color: #1f2329;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}
.btn-secondary:hover { background: #e5e6eb; }

/* ============ Status ============ */
.status-msg {
  margin-top: 12px;
  font-size: 13px;
  text-align: left;
  min-height: 18px;
  line-height: 1.6;
  white-space: pre-line;
  padding: 0 8px;
}
.status-msg.success { color: #00b42a; }
.status-msg.error {
  color: #f53f3f;
  background: #fff5f5;
  border: 1px solid #ffccc7;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 12px;
}

/* ============ Success Card ============ */
.success-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  text-align: center;
}
.success-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 12px;
}
.success-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: #00b42a;
  margin-bottom: 12px;
}
.success-card p {
  font-size: 14px;
  color: #4e5969;
  line-height: 1.6;
  margin-bottom: 8px;
}
.success-card .success-sub {
  font-size: 12px;
  color: #86909c;
  margin-bottom: 20px;
}

.footer { margin-top: 24px; text-align: center; }
.hint {
  font-size: 12px;
  color: #86909c;
  line-height: 1.6;
  padding: 0 12px;
}

/* ============ Mobile tweaks ============ */
@media (max-width: 480px) {
  .item-row-grid {
    grid-template-columns: 1fr 1fr 70px 28px;
    gap: 6px;
  }
  .item-row .remove-row {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  .header h1 { font-size: 20px; }
  .success-icon { font-size: 48px; }
  .dict-stats { font-size: 11px; }
}
